interesting behavior of ComboBox

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
 
C

Cor Ligthert[MVP]

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
 

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

Top