Thursday, 15 March 2012

winforms - Setting selected item in F# ComboBox -


This is driving me crazy ....

I select "Selected" Windows Items of the Forms.ComboBox I tried to do everything but nothing has worked so far. I'm sure something is visible to me ...

Here I have (in F #):

  type foo = {id: int; Name: string; } Let's Fuse = [// List of Fuos] // I want comboBox to display it by default defFoo = {id = 3; Name = "defaultFoo"; } Let's CB = new combo box (cb.DataSource & lt; - foos | & Gt; List. Toure CB Displaymember & lt; - "name" cb.ValueMember & lt; - "id" cb.SelectedValue & lt; - DefFoo.id  

The last line does not work, as I tried none of the other methods (I tried SelectedItem , SelectedIndex , etc.)

I do not use F #, but I think That form needs to be present before doing compulsive work, so try using loaded or shown events:

  yourForm.Load.Add (fun evArgs -> CB Selected value & lt ; - defFoo.id)  

No comments:

Post a Comment