hello... Salamt 4 all
how can i add ListBox to DGrid
& make it easy 4 Data Entry
thankx 4 all advance
------------------
nice 2B Important , but it's more Important 2B nice
Printable View
hello... Salamt 4 all
how can i add ListBox to DGrid
& make it easy 4 Data Entry
thankx 4 all advance
------------------
nice 2B Important , but it's more Important 2B nice
Hi
_____________________________________________
First create a button for the required column in the form load event.
' Place a button in the CustType column
dbParts_Main.Columns("Description").Button = True
_____________________________________________
Then if you click in the column where your button was created.
Private Sub dbParts_Main_BeforeColEdit(ByVal colindex As Integer, ByVal KeyAscii As Integer, Cancel As Integer)
' BeforeColEdit is called before the grid enters into
' edit mode. You can decide what happens and whether
' standard editing proceeds. This allows you to
' substitute different kinds of editing for the current
' cell, as is done here.
If dbParts_Main.Columns(colindex).DataField = "Description" Then
' Let the user edit by entering a key.
If KeyAscii <> 0 Then Exit Sub
' Otherwise, cancel built-in editing and call the
' ButtonClick event to drop down the appropiate list.
Cancel = True
dbParts_Main_ButtonClick (colindex)
End If
End Sub
_____________________________________________
Then when you click on the button.
Private Sub dbParts_Main_ButtonClick(ByVal colindex As Integer)
Dim index As Integer
' Assign the Column object to Co because it will be used
' more than once.
Dim Co As Column
Set Co = dbParts_Main.Columns(colindex)
'postion the components list to the appropiate cell
lstComp(0).Left = dbParts_Main.Left + Co.Left + Co.Width
lstComp(0).Top = dbParts_Main.Top + dbParts_Main.RowTop(dbParts_Main.Row)
lstComp(0).Visible = True
lstComp(0).Text = dbParts_Main.SelText
lstComp(0).ZOrder 0
lstComp(0).SetFocus
End Sub
____________________________________________
Then when you click on the list
Private Sub lstComp_dblClick(index As Integer)
' When an item is selected in Listcomp, copy its value to the
' txtcomp, then make listcomp invisible.
' When an item is selected in lstComp, copy its index to the
' proper column in DBGrid1, then make the List invisible.
Select Case index
Case 0
dbParts_Main.Columns("Description").Text = lstComp(0).Text
lstComp(0).Visible = False
Case 1
'if we click on the second listbox
txtComponent.Text = lstComp(1).Text
lstComp(1).Visible = False
End Select
End Sub
---------------------------------------------
Hope this help