vijay shankar
New member
- Joined
- Mar 27, 2005
- Messages
- 4
- Programming Experience
- 1-3
I am trying to insert combobox in a datagrid. Here is the full code(vb.net)
Dim WithEvents myTextBoxColumn As DataGridTextBoxColumn
Dim WithEvents myGridTextBox As DataGridTextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As New DataSet()
Dim da As New SqlDataAdapter("select buildtype from btype", "data source=PROJECT-NEW;initial catalog=TAXREVISION;persist security info=False;user id=VSankar;pwd=vsankar")
da.Fill(ds, "btype")
DataGrid1.DataSource = ds.Tables(0)
ComboBox1.Items.Add("vijj")
ComboBox1.Items.Add("shan")
' Assumes the CompanyName column is a DataGridTextBoxColumn.
myTextBoxColumn = CType(DataGrid1.TableStyles(0). _
GridColumnStyles("buildtype"), DataGridTextBoxColumn)
' Gets the DataGridTextBox for the column.
myGridTextBox = CType(myTextBoxColumn.TextBox, DataGridTextBox)
End Sub
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
myTextBoxColumn.TextBox.Controls.Add(ComboBox1)
MsgBox(Me.ComboBox1.Location.X)
MsgBox(Me.ComboBox1.Location.Y)
ComboBox1.BringToFront()
ComboBox1.Visible = True
DataGrid1.Refresh()
End Sub
When I click on column the combobox disappears. The location suggests that the cmbobox is where it originally was. I have used sql as backend.Please helpme.
Dim WithEvents myTextBoxColumn As DataGridTextBoxColumn
Dim WithEvents myGridTextBox As DataGridTextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As New DataSet()
Dim da As New SqlDataAdapter("select buildtype from btype", "data source=PROJECT-NEW;initial catalog=TAXREVISION;persist security info=False;user id=VSankar;pwd=vsankar")
da.Fill(ds, "btype")
DataGrid1.DataSource = ds.Tables(0)
ComboBox1.Items.Add("vijj")
ComboBox1.Items.Add("shan")
' Assumes the CompanyName column is a DataGridTextBoxColumn.
myTextBoxColumn = CType(DataGrid1.TableStyles(0). _
GridColumnStyles("buildtype"), DataGridTextBoxColumn)
' Gets the DataGridTextBox for the column.
myGridTextBox = CType(myTextBoxColumn.TextBox, DataGridTextBox)
End Sub
Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
myTextBoxColumn.TextBox.Controls.Add(ComboBox1)
MsgBox(Me.ComboBox1.Location.X)
MsgBox(Me.ComboBox1.Location.Y)
ComboBox1.BringToFront()
ComboBox1.Visible = True
DataGrid1.Refresh()
End Sub
When I click on column the combobox disappears. The location suggests that the cmbobox is where it originally was. I have used sql as backend.Please helpme.