interesting behavior of ComboBox

  • Thread starter Thread starter Kayıhan
  • Start date Start date
K

Kayıhan

here are the steps:
1)create old "windows Forms Application" project
2)in design mode,drag-drop combobox component into the form
3)in the constructer,after " InitializeComponent()" , craete a datatable
and fill it with some data,set combobox.datasource to datatable,set
valuemember,and finally
set combobox.text to "<BLANK>".

when you compile and run it; you ll see your combobox inialized with
"<Blank>" and when drop-down you can see your data from datable.

so far we are good, nothing is strange..

problem is when you create your combobox programmatically (not from designer),
your "<BLANK>" disappears, you get only datatable data.
to call back your "<BLANK>" you have to reset it using form.shown or
form.load event.

what is the reason of it?


appreciate for answers
 
Kayhan,

Simply see in the designer.cs where the code is different from what you
made.

There is in this nothing done behind the scene.

Cor
 
Back
Top