使datagrid从vb6中的组合框中获取价值

时间:2019-01-01 12:34:35

标签: vb6

我正在用vb6开发一个项目,我需要让datagridcombobox的文字

我尝试了datagrid1.text=combo1.text,但没有结果

Private Sub DataGrid1_BeforeColEdit(ByVal ColIndex As Integer, ByVal KeyAscii As Integer, Cancel As Integer)


With DataGrid1
    ' if this is a date column, edit it with the date picker control
    If ColIndex = 2 Then

        ' we'll handle the editing ourselves
        Cancel = True

        ' position date picker control over cell
        'dtPick.Move Grilla.CellLeft + 250, Grilla.CellTop + 150, Grilla.CellWidth, Grilla.CellHeight

        Combo1.Move .Columns(ColIndex).Width, .RowTop(.Row) + .Top, .Columns(ColIndex).Left + .Left

        ' initialize value, save original in tag in case user hits escape
        'Combo1.Text = .Text
        Combo1.Tag = .Text

        ' show and activate date picker control
        Combo1.Visible = True
        Combo1.SetFocus
        Combo1.ZOrder
        ' make it drop down the calendar
        'SendKeys "{f4}"

    End If
End With
End Sub

Private Sub combo1_LostFocus()
' hide date picker when user is done with it
Combo1.Visible = False
End Sub
Private Sub combo1_Change()
' update grid value whenever the data changes
 'DataGrid1.Text = Combo1.Text
DataGrid1.Columns(2).Text = Combo1.ListIndex
Combo1.Text = DataGrid1.Text
End Sub
Private Sub combo1_KeyDown(KeyCode As Integer, Shift As Integer)

' close date picker when user hits escape or return
Select Case KeyCode
    Case vbKeyEscape
        'grilla = dtPick.Tag
        Combo1.Visible = False
    Case vbKeyReturn
        Combo1.Visible = False
End Select

End Sub

我期望得到以下输出:当我单击datagrid行时显示组合框,而当我从中选择一个值时,用户将使用已选择的组合文本的行

0 个答案:

没有答案