Handling Valuemember of Combox placed in a grid
-
With the help from Code Project site I have been successful in placeing various controls in grid. Now it has two three shortcomings (!) as of now. 1. If I use datatable as datasource to combobox placed in datagrid, assign "Name" and "Id" as Display and Value member respectively, In "SelectedValueChange" event it returns "Name" as Displaymember and "Id" as Valuemember instead of actual values. The combobox shows proper values of "Name". 2. I tried to assign values of datagrid cell to datatable row element as follows but it did not work... table.rows(1).Itemarray(1) = dgGrid(CurrentRowIndex,3) above line is indicative, actual code has proper names for table, grid, etc. also put in a loop to iterate. any solution to these issues are welcome.
thanks, Madhav
-
With the help from Code Project site I have been successful in placeing various controls in grid. Now it has two three shortcomings (!) as of now. 1. If I use datatable as datasource to combobox placed in datagrid, assign "Name" and "Id" as Display and Value member respectively, In "SelectedValueChange" event it returns "Name" as Displaymember and "Id" as Valuemember instead of actual values. The combobox shows proper values of "Name". 2. I tried to assign values of datagrid cell to datatable row element as follows but it did not work... table.rows(1).Itemarray(1) = dgGrid(CurrentRowIndex,3) above line is indicative, actual code has proper names for table, grid, etc. also put in a loop to iterate. any solution to these issues are welcome.
thanks, Madhav
for problem one can you paste your code your should have somthing like ComboBox.DisplayMember = "table.colum" ComboBox.ValueMember = "table.colum2" Private Sub ComboBox_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox.SelectedValueChanged TextBox.Text = ComboBox2.SelectedValue End Sub this should give you whatever record is in colum2 when colum one is selected make sure you spell the table and colum values right or it WILL give you just the text a good trick is if you are setting programically get the values by setting in designer first then just copy and paste
-
for problem one can you paste your code your should have somthing like ComboBox.DisplayMember = "table.colum" ComboBox.ValueMember = "table.colum2" Private Sub ComboBox_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox.SelectedValueChanged TextBox.Text = ComboBox2.SelectedValue End Sub this should give you whatever record is in colum2 when colum one is selected make sure you spell the table and colum values right or it WILL give you just the text a good trick is if you are setting programically get the values by setting in designer first then just copy and paste