VB 6.0 - Datagrid with Controls e g textbox, Combo box

Asked By Ralph Acido on 19-Jun-06 10:48 PM
Is there such a way that i could place a controls like Combo box, texbox inside a data grid control in VB 6.0 so that when i add a data onto the datagrid i will select a list in the control... or suggestion what control will i use? Thanks...

code for combo box in data grid - Asked By Rupali Randhave Kolhe on 20-Jun-06 12:11 AM

Option Explicit 


      Private Sub datagrid1_MouseUp(Button As Integer, _ 
         Shift As Integer, x As Single, y As Single) 
          Static CurrentWidth As Single 
          ' Check to see if the columns(1).'s width has changed. 
          If DataGrid1.Columns(1).Width <> CurrentWidth Then 
              Combo1.Width = DataGrid1.Columns(1).Width 
              CurrentWidth = DataGrid1.Columns(1).Width 
          End If 
      End Sub 


      Private Sub Form_Load() 
Combo1.Visible = False 
          Combo1.ZOrder (0) 
          Combo1.Width = DataGrid1.Columns(2).Width 
          ' Load the ComboBox's list. 
          Combo1.AddItem "Some text" 
          Combo1.AddItem "Some more text" 
          Combo1.AddItem "Still more text" 
          Combo1.AddItem "Yet even more text" 
          Combo1.AddItem "Way more text than that" 
      End Sub 


      Private Sub datagrid1_Click() 


                  ' Position and size the ComboBox, then show it. 
           Combo1.Top = DataGrid1.Columns(2).Top 
          Combo1.Width = DataGrid1.Columns(2).Width 
          Combo1.Left = DataGrid1.Columns(2).Left + DataGrid1.Left 
          Combo1.Top = DataGrid1.Columns(2).Top + DataGrid1.Top 
          Combo1.Text = DataGrid1.Columns(2).Text 
          Combo1.Visible = True 
      End Sub 


      Private Sub Combo1_Click() 
          ' Place the selected item into the columns(1). and hide the 
ComboBox. 
          DataGrid1.Columns(2).Text = Combo1.Text 
          Combo1.Visible = False 
      End Sub 


Before using this code connect the datagrid to any table of your data base 
that you 
want to update.