The question is: can I use a FlexGrid (or any of the similar objects) as an Excel spreadsheet to wite data in the cells?
I only can use it to fill the cells by programming routines, not as a keyboard entry.
Printable View
The question is: can I use a FlexGrid (or any of the similar objects) as an Excel spreadsheet to wite data in the cells?
I only can use it to fill the cells by programming routines, not as a keyboard entry.
There is no direct way to do this but, have a look at the following, it may help :)
VB Code:
Option Explicit ' to store the row/column of the cell ' being edited Dim m_lCellCol As Long Dim m_lCellRow As Long Private Sub Form_Load() m_lCellRow = -1 m_lCellCol = -1 txtCell.BorderStyle = 0 txtCell.Visible = False ' set the text background color to the ' backcolor of the tooltip text to make ' the cell being edited having a different color txtCell.BackColor = vbInfoBackground MSFlexGrid1.Cols = 10 MSFlexGrid1.Rows = 10 End Sub Private Sub MSFlexGrid1_DblClick() showTxtCell End Sub Private Sub MSFlexGrid1_RowColChange() removeTxtCell End Sub Private Sub MSFlexGrid1_Scroll() removeTxtCell End Sub Private Sub MSFlexGrid1_SelChange() removeTxtCell End Sub Private Sub txtCell_Change() MSFlexGrid1.Text = txtCell.Text End Sub Private Sub showTxtCell() If m_lCellRow = -1 Then With MSFlexGrid1 ' store the current row and column m_lCellRow = .Row m_lCellCol = .Col ' move the textbox to the correct cell txtCell.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight txtCell.Text = .Text ' select all text txtCell.SelLength = Len(.Text) End With txtCell.Visible = True txtCell.SetFocus End If End Sub Private Sub removeTxtCell() If m_lCellRow <> -1 Then MSFlexGrid1.TextMatrix(m_lCellRow, m_lCellCol) = txtCell.Text m_lCellRow = -1 m_lCellCol = -1 txtCell.Visible = False End If End Sub Private Sub txtCell_Validate(Cancel As Boolean) removeTxtCell End Sub
For this you will need to add a Textbox control called: txtCell also :)
Not writtne by me...
Cheers,
RyanJ
Thanks :b: