|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Combo Boxes in DatagridsIt seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table in a different dataset. One combo box is displaying the Employees payroll ID. The other is displaying the Employees name. The users are entering timesheet hours for employees. They want to be able to select the employee by either payroll id, or employee name. If they select a payroll id from the first combo box, I need the second combo box to display the matching employee surname. I cannot see anyway to do this. I can only seem to get the selected index of the combo box being selected. (by using the editing control event and casting the datagrid comboboxcolumn to a combo box). However, I dont know how I can set the selected index of the other combo box. Can anyone help? (besides telling me to buy some third party control!) thankyou Hi there,
Sounds like you've had problems getting help. I'll try as best I can but need you to provide some more info first. 1. Windows or web application? .NET 1.1 I presume? 2. Post some code; specifically where you do your binding/fill the combos. If you can get a reference to the actual combobox in question, then it should not be too hard to select the right item. But assigning the right information to the combobox in the first place is the important part. For example, in windows app, you can iterate through the items collection and check each item's bound row for a match to the ID selected in the other cbx. Steven Im using version 2.0
This is a windows form. I am using the standard DatagridView. This is bound to a dataset generated by the dataset designer. I have gone into the designer for the DataGridView and changed the properties of the two columns previously mentioned to combo boxes (instead of text boxes). On the form load, I create a dataset and use stored procedures to populate various tables with lookup data. I then bind the combo boxes in the datagrid to these dataset tables eg with DataGridCombo1 .DisplayMember = "EmpCode" .ValueMember = "Surname" .DataSource = dsLookups.Tables("EmplsCodeLookup") end with now...teh comboboxes that are embedded in the datagrid do not have the selectedindex property available... so, if the user selects a value in one combo box, to get the selected index of that combo box I have to do the following Private Sub TblTimeSheetHoursDataGridView_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles TblTimeSheetHoursDataGridView.EditingControlShowing Dim combo As ComboBox = CType(e.Control, ComboBox) If (combo IsNot Nothing) Then Select Case TblTimeSheetHoursDataGridView.CurrentCell.ColumnIndex Case 2 RemoveHandler combo.SelectedIndexChanged, _ New EventHandler(AddressOf EmplCodeComboBox_SelectedIndexChanged) .... .... .... end sub Which is all well and good, I now have the selected index of the combo box the user has just selected. However, I now need to programmatically set the index of the other combo box.... What i want to know is.....how do I do this (given that the editing control event had to be raised to get the selected index of the other combo!!). Surely this is possible somehow!? Please help Hi again,
No problems. If you can wait on the problem for another 24 hours, I will attempt to recreate your problem at home tonight and find an answer for you. Unfortunately I do not have 2.0 here at work (yes we are a little behind the times). Cheers, Steven Ausclad wrote: Show quoteHide quote > Im using version 2.0 > > This is a windows form. > > I am using the standard DatagridView. This is bound to a dataset generated > by the dataset designer. > > I have gone into the designer for the DataGridView and changed the > properties of the two columns previously mentioned to combo boxes (instead of > text boxes). > > On the form load, I create a dataset and use stored procedures to populate > various tables with lookup data. > > I then bind the combo boxes in the datagrid to these dataset tables > > eg > with DataGridCombo1 > .DisplayMember = "EmpCode" > .ValueMember = "Surname" > .DataSource = dsLookups.Tables("EmplsCodeLookup") > end with > > now...teh comboboxes that are embedded in the datagrid do not have the > selectedindex property available... > > so, if the user selects a value in one combo box, to get the selected index > of that combo box I have to do the following > > > Private Sub TblTimeSheetHoursDataGridView_EditingControlShowing(ByVal sender > As Object, ByVal e As > System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles > TblTimeSheetHoursDataGridView.EditingControlShowing > Dim combo As ComboBox = CType(e.Control, ComboBox) > If (combo IsNot Nothing) Then > > Select Case TblTimeSheetHoursDataGridView.CurrentCell.ColumnIndex > Case 2 > RemoveHandler combo.SelectedIndexChanged, _ > New EventHandler(AddressOf > EmplCodeComboBox_SelectedIndexChanged) > ... > ... > ... > end sub > > Which is all well and good, I now have the selected index of the combo box > the user has just selected. However, I now need to programmatically set the > index of the other combo box.... > > What i want to know is.....how do I do this (given that the editing control > event had to be raised to get the selected index of the other combo!!). > > Surely this is possible somehow!? > > Please help Ausclad,
If you want help, than give correct questions, the help for a Combobox in a DataGrid is much more work and completely different than for a DataGridView. The way you ask your questions gives me not the right feeling to help you. Maybe the next time, when you let us not first search to a complete different solution just because you are no lazy to write correctly your problem. Just my thought, Cor Show quoteHide quote "Ausclad" <Ausc***@discussions.microsoft.com> schreef in bericht news:D6F36C83-B2DA-482D-9C4B-AEEE4DB16153@microsoft.com... > Im using version 2.0 > > This is a windows form. > > I am using the standard DatagridView. This is bound to a dataset > generated > by the dataset designer. > > I have gone into the designer for the DataGridView and changed the > properties of the two columns previously mentioned to combo boxes (instead > of > text boxes). > > On the form load, I create a dataset and use stored procedures to populate > various tables with lookup data. > > I then bind the combo boxes in the datagrid to these dataset tables > > eg > with DataGridCombo1 > .DisplayMember = "EmpCode" > .ValueMember = "Surname" > .DataSource = dsLookups.Tables("EmplsCodeLookup") > end with > > now...teh comboboxes that are embedded in the datagrid do not have the > selectedindex property available... > > so, if the user selects a value in one combo box, to get the selected > index > of that combo box I have to do the following > > > Private Sub TblTimeSheetHoursDataGridView_EditingControlShowing(ByVal > sender > As Object, ByVal e As > System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles > TblTimeSheetHoursDataGridView.EditingControlShowing > Dim combo As ComboBox = CType(e.Control, ComboBox) > If (combo IsNot Nothing) Then > > Select Case > TblTimeSheetHoursDataGridView.CurrentCell.ColumnIndex > Case 2 > RemoveHandler combo.SelectedIndexChanged, _ > New EventHandler(AddressOf > EmplCodeComboBox_SelectedIndexChanged) > ... > ... > ... > end sub > > Which is all well and good, I now have the selected index of the combo box > the user has just selected. However, I now need to programmatically set > the > index of the other combo box.... > > What i want to know is.....how do I do this (given that the editing > control > event had to be raised to get the selected index of the other combo!!). > > Surely this is possible somehow!? > > Please help > > > > > Wow Cor, I think you came in a little too strong this time.
> If you want help, than give correct questions People can't always word the question as perfectly as we would like.That's why I asked the clarification questions. Now days, if anyone ever asks about DataGrids, I always first check what framework version they are running, just in case. It so happens that this time it paid off. I suppose I got lucky... > The way you ask your questions gives me not the right feeling to help you. I guess thats up to you. You are well within your rights to refuse toanswer anyones questions. > Maybe the next time, when you let us not first search to a complete I don't think laziness has anything to do with it in this posting. The> different solution just because you are no lazy to write correctly your > problem. OP merely ommitted a single word "View" that simply happened to have a large impact on the solution. While I concur that this can be frustrating, I think a more educational approach for the OP is to simply advise them of the impact of their error and the consequences. This lets the OP have a chance at apologising for their mistake. But coming out and attacking straight off the bat is not going to help anyone. Anyway, lets see if we can find an answer for him, shall we? I don't have .NET2.0 here but I can look at it tonight if no one else can help now... Steven Steven,
I do not like those people who give a lot of work, for the same case I would have send some links for combobox datagrids and given some help. You can use the DataGrids in any version of Net. What is wrong to describe a question good, instead of something as. "I have a problem with my Combo Boxes in Datagrids" Who says that it is in this case about Comboboxes and not about a Calendar Control. It can in my opinion not be a problem. My message was also meant to show to others that we should not help in these cases that people don't take even the time to put there question right, in my idea have those people not even investigated their problems and do I completely agree what Boo often writes.. But feel free to help. Cor Show quoteHide quote "Steven Nagy" <learndot***@hotmail.com> schreef in bericht news:1160367527.552745.4640@i3g2000cwc.googlegroups.com... > Wow Cor, I think you came in a little too strong this time. > >> If you want help, than give correct questions > > People can't always word the question as perfectly as we would like. > That's why I asked the clarification questions. Now days, if anyone > ever asks about DataGrids, I always first check what framework version > they are running, just in case. It so happens that this time it paid > off. > I suppose I got lucky... > >> The way you ask your questions gives me not the right feeling to help >> you. > > I guess thats up to you. You are well within your rights to refuse to > answer anyones questions. > >> Maybe the next time, when you let us not first search to a complete >> different solution just because you are no lazy to write correctly your >> problem. > > I don't think laziness has anything to do with it in this posting. The > OP merely ommitted a single word "View" that simply happened to have a > large impact on the solution. While I concur that this can be > frustrating, I think a more educational approach for the OP is to > simply advise them of the impact of their error and the consequences. > This lets the OP have a chance at apologising for their mistake. But > coming out and attacking straight off the bat is not going to help > anyone. > > Anyway, lets see if we can find an answer for him, shall we? I don't > have .NET2.0 here but I can look at it tonight if no one else can help > now... > > Steven > Well thanks Cor for that complete and utter gibberish.
The whole point of these forums, I thought, was for people who do not have a complete understanding of the .net framework to seek some guidance from those who do. Since I am new to .net I was not aware that there was/is a datagrid and a datagridview. Since my version only shipped with a DataGridView I (wrongly) assumed the generic term "datagrid" was adequate. My humble apologies! Given that I spent a good 5-6 hours attempting this task and googling to find a solution first I think I have at least given it reasonable thought before posting the question. Given the way you write, there no way I could convert my question into something you could possibly understand anyway. Steven, thanks for being the kind of person this forum needs. I look forward to any further help you are able to provide. thanks
Experience Request: GPS Application
What is the optimal way to upload 10,000 records to Oracle DB? Multi-dimensional array - Question on Data types How do I replace unwanted characters from a string using Reg Exp? How to debug program error on Windows with another language? Prompting for an IP address Tab groups in VB2003 debugging Access DB on a pocket PC Connect to the right SQL Server during runtime How can I get the data type of a data table's columns? |
|||||||||||||||||||||||