ListBox SelectItem

  • Thread starter Thread starter Dom
  • Start date Start date
D

Dom

I populate a ListBox in the Form's Load event. I want to select a
default item, but apparently, I can't do that in the Load Event. (I
remember that was a problem in VB also). Where is the best place to
do this?

In general, what are the order of events in CSharp? In VB we had the
I LOATHE RAP rule -- Init, Load, Resize, Activate, Paint.
 
Odd - I haven't hit that myself... but perhaps (as an untested, off
the wall idea) you could BeginInvoke to an inline to do this once the
form starts pumping its message queue? i.e.

int selectedIndex = 16; // or whatever
BeginInvoke((MethodInvoker) delegate {
myList.SelectedIndex = selectedIndex;
});

Don't use Invoke(), as this will execute immediately, which isn't what
you want.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top