DataBinding

J

Jim Heavey

If I set the I change the DropDownStyle propety of a ComboBox to
DropDownList, can the the SelectedIndex propety ever be a -1? It seems no
matter what I do, when I bind the comboBox to a datasource and set the
DropDownStyle to DropDownList, it always shows the first row value.

When this control is bound to a datasource (DataTable) and the ValueMember
and Display Member properties are set appropriately, when I attempt to
retrieve the SelectedValue from the ComboBox, rather then retrieving the
value, as I expected and as I believe the documentation states it will, I
get "System.Data.DataRowView" being returned. What am I doing wrong?
 
J

Jim Heavey

One important thing that I left off my previous note is that this is
occuring during the binding process, after the binding process has
completed, then the SelectedValue does indeed return the value.

Normally, I would check the SelectedIndex property to see if it is a -1 and
exit the routine, but as my previous not indicated, the control is not
comming to me as -1, so I am not sure what logic I would use to exit when
nothing is really selected.

So how to I exit the routine if I can not check the selectedIndex property
to determine nothing has been selected?
 

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