利用一个textbox增加MsFlexGrid 的编辑功能的问题
在vb中利用下面代码可以实现利用一个textbox增加MsFlexGrid 的编辑功能(MsFlexGrid 可以设置为处于最底层),而在vba中却不可以(由于MsFlexGrid 总是处于最顶层),为什么?怎么改?Public i As Integer<BR>Public j As Integer<BR>Private Sub MSFlexGrid1_Click()<BR> TextBox1.Visible = False<BR>End Sub
Private Sub MSFlexGrid1_DblClick()<BR>i = MSFlexGrid1.Col<BR> j = MSFlexGrid1.Row<BR>With MSFlexGrid1<BR>TextBox1.Move .Left + .CellLeft, .top + .CellTop, .CellWidth, .CellHeight<BR> TextBox1.Text = .Text<BR> TextBox1.Visible = True<BR> TextBox1.SetFocus<BR>End With<BR>End Sub
Private Sub MSFlexGrid1_Scroll()<BR> TextBox1.Visible = False<BR>End Sub
Private Sub textbox1_LostFocus()
MSFlexGrid1.TextMatrix(j, i) = TextBox1.Text<BR>TextBox1.Visible = False<BR>End Sub
Private Sub UserForm_Initialize()<BR>TextBox1.Visible = False
<BR> MSFlexGrid1.Rows = 10<BR> MSFlexGrid1.Cols = 2<BR> MSFlexGrid1.FixedCols = 1<BR> MSFlexGrid1.FixedRows = 0<BR> <BR> MSFlexGrid1.ColWidth(0) = 1600<BR> MSFlexGrid1.ColWidth(1) = 1500<BR> MSFlexGrid1.Row = 0<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a1"<BR> MSFlexGrid1.Row = 1<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a2"<BR> MSFlexGrid1.Row = 2<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a3"<BR> MSFlexGrid1.Row = 3<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a4"
MSFlexGrid1.Row = 4<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a5"<BR> MSFlexGrid1.Row = 5<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a6"<BR> MSFlexGrid1.Row = 6<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a7"<BR> MSFlexGrid1.Row = 7<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a8"<BR> MSFlexGrid1.Row = 8<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a9"<BR> MSFlexGrid1.Row = 9<BR> MSFlexGrid1.Col = 0<BR> MSFlexGrid1.Text = "a10" <BR>End Sub 是不是问题太简单了,怎么没有人告诉我 VBA中是不太好用,试试DB Grid吧,那个控件直接可以编辑。
页:
[1]