28-01-18, 02:24 PM
لقد تم الحل وقمت بتطوير هذا الكود .. و شكرا لكل المشرفين !! .. و اتمنى للجميع الاستفادة منه ..
كود :
STEP1 - Put a DBGrid Control on a Form and connect it to a Data Control
STEP2 - put a combo box over the DBGrid and set the visible property to False and set the
width of the Combo equal to width of a particular Column of DbGrid control,
which you want to populate the data.
STEP3 - Add the following code in Form_Load, DbGrid1_Rowcolchange and Combo1_Click() Events
Private Sub Form_Load()
'POPULATE THE COMBO BOX WITH THE DESIRED VALUES
Combo1.AddItem "MYTEXT1"
Combo1.AddItem "MYTEXT2"
Combo1.AddItem "MYTEXT3"
'ALTERNATIVELY, COMBO BOX CAN ALSO BE POPULATED WITH DATA FROM A TABLE.
End Sub
Private Sub DBGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Dim Currentrow, CurrentCol
Currentrow = DBGrid1.Row
CurrentCol = DBGrid1.Col
' HERE THE VALUE 2 MEANS, THE PARTICULAR
'COLUMN WHICH REQUIRES THE LIST OF DATA
' FROM COMBO BOX.
If CurrentCol = 2 Then
Combo1.Visible = True
Combo1.Top = Me.DBGrid1.RowTop(Currentrow) + DBGrid1.RowHeight
Combo1.Left = 1950
Combo1.Width = 980
Combo1.Text = DBGrid1.Text ' ASSIGNING
' PARTICULAR CELL VALUE OF DBGRID TO COMBO
Else
Combo1.Visible = False
End If
End Sub
Private Sub Combo1_Click()
DBGrid1.Col = 2
DBGrid1.Text = Me.Combo1.Text ' ASSIGNING THE
' COMBO VALUE TO PARTICULAR CELL OF DBGRID
End Sub