Hi Mika, Set a breakpoint immediately after cbocombo1.selectedindex = -1 just to see if it goes to -1 (empty) for an instant; if this is the case (I'm guessing it is), then it is code that follows this code that is resetting combos 1 and 2 to another index. HTH, Bernie Yaeger [quoted text, click to view] "Mika M" <mika .m a h o n e n@kolumbus.fi> wrote in message news:uc1F6$d5DHA.2392@TK2MSFTNGP11.phx.gbl... > 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 :) > > -- > Thanks for your help in advance! > > Mika > >
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 :) -- Thanks for your help in advance! Mika
Hi Mika, HTH means 'hope this helps'. OK, let's see - is the field name 2 words? If it is, you should bracket it ([....]) in the select. Also, try another field from the table in question; any field, just to see if it's the field or the table that's causing the problem. Can you send me an .xml of the tables in question? If you can, I would try to replicate the conditions on my system. HTH, Bernie [quoted text, click to view] "Mika M" <m i k a .mahonen@kolumbus.fi> wrote in message news:uHTvX7j5DHA.2344@TK2MSFTNGP09.phx.gbl... > > Set a breakpoint immediately after cbocombo1.selectedindex = -1 just to > see > > if it goes to -1 (empty) for an instant; if this is the case (I'm guessing > > it is), then it is code that follows this code that is resetting combos 1 > > and 2 to another index. > > Hello Bernie, and thank you for your reply! > > Yes I tried that already, but it's not the reason for the problem. I tried > to create 'ArticleTypes' - table into DataSet using SELECT-sql query of the > other working ComboBox, and then it was working ok, except using wrong > database table :'(. > > Weird because source tables in database are identical, except > 'ArticleType'-Column Name is not same, but field types and properties are. > I'm using MS SQL 2K version 8.00.760 database. I think there's something > weird with database. > > > HTH, > What does this abbreviation means? Here in Finland we don't have much > abbreviations. In fact our words are quite long :) > > -- Mika > >
[quoted text, click to view] > Set a breakpoint immediately after cbocombo1.selectedindex = -1 just to see > if it goes to -1 (empty) for an instant; if this is the case (I'm guessing > it is), then it is code that follows this code that is resetting combos 1 > and 2 to another index.
Hello Bernie, and thank you for your reply! Yes I tried that already, but it's not the reason for the problem. I tried to create 'ArticleTypes' - table into DataSet using SELECT-sql query of the other working ComboBox, and then it was working ok, except using wrong database table :'(. Weird because source tables in database are identical, except 'ArticleType'-Column Name is not same, but field types and properties are. I'm using MS SQL 2K version 8.00.760 database. I think there's something weird with database. [quoted text, click to view] > HTH,
What does this abbreviation means? Here in Finland we don't have much abbreviations. In fact our words are quite long :) -- Mika
Hi Mika, No, I wouldn't do that - you're creating empty rows, and that will surely get you into trouble down later on. I would rather suggest that you go back to the original code and work with one combobox and one column at a time until you identify the problem. Sorry I don't have any better ideas. Bernie [quoted text, click to view] "Mika M" <mika .m a h o n e n@kolumbus.fi> wrote in message news:uwz25Jq5DHA.1816@TK2MSFTNGP12.phx.gbl... > Hello Bernie, and thank you for your reply again! > > Today I noticed when I pressed 'New'-button twice, then those two problem > ComboBoxes also changed to > > .SelectedIndex = -1. > > In this case when adding new, DataAdapters Update will insert one empty line > and one with forms data into databases parent/master table. Then I added two > lines for these problem ComboBoxes like ... > > thisCurrencyManager.EndCurrentEdit() > thisCurrencyManager.AddNew() > cboCombo1.SelectedIndex = -1 > cboCombo1.SelectedIndex = -1 > cboCombo2.SelectedIndex = -1 > cboCombo2.SelectedIndex = -1 > cboCombo3.SelectedIndex = -1 > cboCombo4.SelectedIndex = -1 > cboCombo5.SelectedIndex = -1 > cboCombo6.SelectedIndex = -1 > > ... well, this is not very clever way to solve this :) but it works - but > why like this way ?!? > > In fact I have also 6 x Grid components on the separate TabPages in the > bottom of the same form for the details (maybe too many for same form, I > have to think this solution again). Pressing once 'New'-button AddNew causes > that 3 Grid components clears, but when 'New'-button again then all grids > are empty - but like few lines above mentioned - DataAdapters Update will > insert one empty line and one with forms data into databases parent/master > table. Any ideas how to try to solve this? > > -- > Thanks for your reply in advance! > > Mika > >
Hello Bernie, and thank you for your reply again! Today I noticed when I pressed 'New'-button twice, then those two problem ComboBoxes also changed to ..SelectedIndex = -1. In this case when adding new, DataAdapters Update will insert one empty line and one with forms data into databases parent/master table. Then I added two lines for these problem ComboBoxes like ... thisCurrencyManager.EndCurrentEdit() thisCurrencyManager.AddNew() cboCombo1.SelectedIndex = -1 cboCombo1.SelectedIndex = -1 cboCombo2.SelectedIndex = -1 cboCombo2.SelectedIndex = -1 cboCombo3.SelectedIndex = -1 cboCombo4.SelectedIndex = -1 cboCombo5.SelectedIndex = -1 cboCombo6.SelectedIndex = -1 .... well, this is not very clever way to solve this :) but it works - but why like this way ?!? In fact I have also 6 x Grid components on the separate TabPages in the bottom of the same form for the details (maybe too many for same form, I have to think this solution again). Pressing once 'New'-button AddNew causes that 3 Grid components clears, but when 'New'-button again then all grids are empty - but like few lines above mentioned - DataAdapters Update will insert one empty line and one with forms data into databases parent/master table. Any ideas how to try to solve this? -- Thanks for your reply in advance! Mika
Don't see what you're looking for? Try a search.
|