I'm working on a program, which included an "editable" grid (MSHFlexGrid). I borrowed code from a VB book, which told me to superimpose a textbox whenever I click a cell.
With MSHFlexgrid1
' Cancel range selection, if any.
.RowSel = .Row
.ColSel = .Col
' Move the cell editor into place by making it one pixel smaller
' than the current cell.
txtCellEditor.Move .Left + .CellLeft, .Top + .CellTop, _
.CellWidth - ScaleX(1, vbPixels, vbTwips), _
.CellHeight - ScaleY(1, vbPixels, vbTwips)
' Transfer the contents of the current cell into the TextBox.
txtCellEditor.Text = .Text
' Move the TextBox in front of the grid.
txtCellEditor.Visible = True
txtCellEditor.ZOrder
txtCellEditor.SetFocus
' Remember current coordinates for later.
cellRow = .Row
cellCol = .Col
End With
I really don't see any problem with the code. I just don't know why the textbox (txtCellEditor) won't show whenever I invoke the click button on the grid. More surprisingly, the data I enter in the textbox is entered into the grid after the textbox loses focus. Just wondering how to make that textbox appear and let the user see what he is editing.
Hope anyone can help. Thanks in advance!!!
With MSHFlexgrid1
' Cancel range selection, if any.
.RowSel = .Row
.ColSel = .Col
' Move the cell editor into place by making it one pixel smaller
' than the current cell.
txtCellEditor.Move .Left + .CellLeft, .Top + .CellTop, _
.CellWidth - ScaleX(1, vbPixels, vbTwips), _
.CellHeight - ScaleY(1, vbPixels, vbTwips)
' Transfer the contents of the current cell into the TextBox.
txtCellEditor.Text = .Text
' Move the TextBox in front of the grid.
txtCellEditor.Visible = True
txtCellEditor.ZOrder
txtCellEditor.SetFocus
' Remember current coordinates for later.
cellRow = .Row
cellCol = .Col
End With
I really don't see any problem with the code. I just don't know why the textbox (txtCellEditor) won't show whenever I invoke the click button on the grid. More surprisingly, the data I enter in the textbox is entered into the grid after the textbox loses focus. Just wondering how to make that textbox appear and let the user see what he is editing.
Hope anyone can help. Thanks in advance!!!