Hi!
I've just written a form. In this form, I extract some data from the db
for a given combobox when loading the form. The problem is this, when I
fail to select an item from this combobox and store my changes, I still
observe that the first combobox-item is stored in my new table (that
means, it is chosen automatically). Is there any way I can avoid this?
I have the following in my load_method:
private void Form1_Load(object sender, EventArgs e)
{
commandTxt = "select no, name1 from ...";
tblDeliver = SelectStatementsData(commandTxt);//gets the rows
if (tblDeliver != null)
{
this.comboBoxDeliver.DataSource = tblDeliver;
//names are displayed in combo, but works with no (id)
this.comboBoxDeliver.ValueMember = "no";
this.comboBoxDeliver.DisplayMember = "name1";
}
else
MessageBox.Show(ExceptionMsg);
}
Tried to manipulate it in SelectedIndexChanged, but to no avail:
private void comboBoxDeliver_SelectedIndexChanged(object sender,
EventArgs e)
{
if (comboBoxDeliver.SelectedItem.ToString() != null)
{
comboBoxDeliver.SelectedValue.ToString();
}
else
MessageBox.Show("Deliverer does not exist");
------------------------------------------
How can I manipulate it so that nothing could appear in the first line
of combobox by loading? or/and
How can I make sure that if I select nothing from the combo, nothing
will be stored in the db on saving?
Thanks in advance,
Stropher