gpt4 book ai didi

vb6 - MSFlexGrid 编辑 VB6

转载 作者:行者123 更新时间:2023-12-05 00:31:59 35 4
gpt4 key购买 nike

目前我正在研究 vb6 应用程序。我想在 MSFlexgrid 中显示数据 但是 MSFlexgrid Control 中没有编辑工具。

有没有办法编辑 MSFlexgrid?

最佳答案

有一种使用隐藏文本框的方法。在单元格上双击文本框将可见并且可以编辑这里是代码片段检查它

Private Sub Form_Load()

'Setting Col And row

MSFlexGrid1.Cols = 3
MSFlexGrid1.Rows = 10
'First row
MSFlexGrid1.TextMatrix(0, 0) = "ID"
MSFlexGrid1.TextMatrix(0, 1) = "Date"
MSFlexGrid1.TextMatrix(0, 2) = "Voucher Type"
'some data
MSFlexGrid1.TextMatrix(1, 0) = "E0000001"
MSFlexGrid1.TextMatrix(2, 0) = "E0000001"
MSFlexGrid1.TextMatrix(1, 1) = "01/04/10"
MSFlexGrid1.TextMatrix(2, 1) = "01/04/10"
MSFlexGrid1.TextMatrix(1, 2) = "Jrnl"
MSFlexGrid1.TextMatrix(2, 2) = "Jrnl"
End Sub

Private Sub MSFlexGrid1_DblClick()

'If MSFlexGrid1.Col = 3 Or MSFlexGrid1.Col = 6 Or MSFlexGrid1.Col = 7 Then
GridEdit Asc(" ")
'End If
End Sub

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

GridEdit KeyAscii

End Sub

Sub GridEdit(KeyAscii As Integer)

'use correct font
Text1.FontName = MSFlexGrid1.FontName
Text1.FontSize = MSFlexGrid1.FontSize

Select Case KeyAscii

Case 0 To Asc(" ")
Text1 = MSFlexGrid1
Text1.text = Trim(Text1.text)
Text1.SelStart = 1000

Case Else
Text1 = MSFlexGrid1
Text1.text = Trim(Text1.text)
Text1.SelStart = 1000

End Select

'position the edit box


Text1.Left = MSFlexGrid1.CellLeft + MSFlexGrid1.Left

Text1.Top = MSFlexGrid1.CellTop + MSFlexGrid1.Top

Text1.Width = MSFlexGrid1.CellWidth

Text1.Height = MSFlexGrid1.CellHeight

Text1.Visible = True

Text1.SetFocus

End Sub

Private Sub MSFlexGrid1_LeaveCell()

If Text1.Visible Then

If MSFlexGrid1.Col = 6 Or MSFlexGrid1.Col = 7 Then
If Text1.text = "" Then
Text1.text = " "
End If
End If
MSFlexGrid1 = Text1
Text1.Visible = False

End If

End Sub

Private Sub MSFlexGrid1_GotFocus()

If Text1.Visible Then

If MSFlexGrid1.Col = 6 Or MSFlexGrid1.Col = 7 Then

If Text1.text = "" Then
Text1.text = " "
End If

End If

MSFlexGrid1 = Text1.text
Text1.Visible = False

End If

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

'noise suppression

If MSFlexGrid1.Col <> 6 And MSFlexGrid1.Col <> 7 Then

KeyAscii = 0

End If

If KeyAscii = vbKeyReturn Then

KeyAscii = 0

End If

End Sub

关于vb6 - MSFlexGrid 编辑 VB6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14008953/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com