TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Brian Tousignant
NA
1
0
How to asynchronously populate combo box on a window form
Aug 17 2009 11:57 AM
Is it possible to populate a combo box after the form has loaded. I've tried the following, the code runs; however, the combo box is empty. What am I missing?
thanks!
namespace TRSWin.Inquiry
{
public delegate TOutput MyAsyncMethod<TOutput>(ref ComboBox myComboBox, object dataSource);
public partial class PositionInquiry : TRSWin.ParentForm
{
public PositionInquiry()
{
InitializeComponent();
}
public bool BindLookup(ref ComboBox myComboBox, object dataSource)
{
myComboBox.DataSource = dataSource;
myComboBox.DisplayMember = "Description";
return true;
}
public void BeginBindLookup(ref ComboBox myComboBox, object dataSource)
{
MyAsyncMethod<bool> method = BindLookup;
method.BeginInvoke(ref myComboBox, dataSource, EndBindLookup, method);
}
public void EndBindLookup(IAsyncResult result)
{
MyAsyncMethod<bool> method = result.AsyncState as MyAsyncMethod<bool>;
//bool b = method.EndInvoke(result); // Can't figure out how to make this call either, so I will ignore for now.
}
private void PositionInquiry_Load(object sender, EventArgs e)
{
BindLookup(ref cboSymbol, Cache.SymbolLookup); // Works, populates list
BeginBindLookup(ref cboSymbol, Cache.SymbolLookup); // Runs, but list is empty
}
}
}
Reply
Answers (
1
)
Windows form control in explorer browser
pop up window