select item in combibox contained within a datagridview in vb.net 2005
Posted on 2007-07-26
I have the following code: -
Public Class Form1
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
If TypeOf e.Control Is ComboBox Then
Dim cbo As ComboBox = CType(e.Control, ComboBox)
Select Case Me.DataGridView1.CurrentRow.Index
cbo.SelectedItem = 1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
What it does is populate a datagridview with a straing column and anothe column with a combibox that is populated individually. When the combibox is populated it does not show the first piece of text i,e, if the combibox has : -
it shows the combibox as being blank until you clikc the down arrow. Usually with standard from combiboxes I use the code: -
cmbtest.selecteditem = 1
but this does not seem to work with combiboxes that are contained within a datagridview.
I would appreciate your help.