M
Mika M
Hello!
I have Windows Forms application form containing TextBoxes, six ComboBoxes,
and DataGrid for details. I have created DataSet with needed tables, and
created relations between tables, and bound controls to datatables.
Everything is working almost fine including saving data, but when I press
'New' - button ...
thisCurrencyManager.EndCurrentEdit()
thisCurrencyManager.AddNew()
cboComBo1.SelectedIndex = -1
cboComBo2.SelectedIndex = -1
cboComBo3.SelectedIndex = -1
cboComBo4.SelectedIndex = -1
cboComBo5.SelectedIndex = -1
cboComBo6.SelectedIndex = -1
....to add new entry, only ComboBoxes 3 to 6 are moving to .SelectedIndex
= -1, but ComboBoxes 1 and 2 to .SelectedIndex = 0 ?!?
QUESTION: Why not these ComboBoxes 1 and 2 are not moving to .SelectedIndex
= -1 too (when AddNew) ?
- All these six ComboBoxes are populated like this same way ...
daArticleTypes = New OleDbDataAdapter(New OleDbCommand("SELECT ID,
ArticleType, Description FROM ARTICLE_TYPES", cnn))
daArticleTypes.Fill(ds, "ArticleTypes")
- Even their source table in database is quite similar ...
ID AutoNumber int
ArticleType nvarchar
Description nvarchar
.... only 'ArticleType' - field has another name in other database tables
because all those tables are storing other kind of basic list.
- All ComboBoxes are bound like this same way ...
cboCombo1.DataSource = ds.Tables("ArticleTypes")
cboCombo1.DisplayMember = "ArticleType"
cboCombo1.ValueMember = "ID"
cboCombo1.DataBindings.Add("SelectedValue", ds, "Products.ArticleTypeID")
- I show ToolTip for the user by the following way in every ComboBoxes ...
Private Sub cboCombo1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cboCombo1.SelectedIndexChanged
Dim cb As ComboBox = CType(sender, ComboBox)
If cb.SelectedIndex > -1 Then
ToolTip1.SetToolTip(cb,
ds.Tables("ArticleTypes").Rows(cb.SelectedIndex).Item("Description").ToStrin
g)
Else
ToolTip1.SetToolTip(cb, Nothing)
End If
End Sub
Hopefully you understand what I'm trying to ask
I have Windows Forms application form containing TextBoxes, six ComboBoxes,
and DataGrid for details. I have created DataSet with needed tables, and
created relations between tables, and bound controls to datatables.
Everything is working almost fine including saving data, but when I press
'New' - button ...
thisCurrencyManager.EndCurrentEdit()
thisCurrencyManager.AddNew()
cboComBo1.SelectedIndex = -1
cboComBo2.SelectedIndex = -1
cboComBo3.SelectedIndex = -1
cboComBo4.SelectedIndex = -1
cboComBo5.SelectedIndex = -1
cboComBo6.SelectedIndex = -1
....to add new entry, only ComboBoxes 3 to 6 are moving to .SelectedIndex
= -1, but ComboBoxes 1 and 2 to .SelectedIndex = 0 ?!?
QUESTION: Why not these ComboBoxes 1 and 2 are not moving to .SelectedIndex
= -1 too (when AddNew) ?
- All these six ComboBoxes are populated like this same way ...
daArticleTypes = New OleDbDataAdapter(New OleDbCommand("SELECT ID,
ArticleType, Description FROM ARTICLE_TYPES", cnn))
daArticleTypes.Fill(ds, "ArticleTypes")
- Even their source table in database is quite similar ...
ID AutoNumber int
ArticleType nvarchar
Description nvarchar
.... only 'ArticleType' - field has another name in other database tables
because all those tables are storing other kind of basic list.
- All ComboBoxes are bound like this same way ...
cboCombo1.DataSource = ds.Tables("ArticleTypes")
cboCombo1.DisplayMember = "ArticleType"
cboCombo1.ValueMember = "ID"
cboCombo1.DataBindings.Add("SelectedValue", ds, "Products.ArticleTypeID")
- I show ToolTip for the user by the following way in every ComboBoxes ...
Private Sub cboCombo1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cboCombo1.SelectedIndexChanged
Dim cb As ComboBox = CType(sender, ComboBox)
If cb.SelectedIndex > -1 Then
ToolTip1.SetToolTip(cb,
ds.Tables("ArticleTypes").Rows(cb.SelectedIndex).Item("Description").ToStrin
g)
Else
ToolTip1.SetToolTip(cb, Nothing)
End If
End Sub
Hopefully you understand what I'm trying to ask