|
-
May 11th, 2005, 11:02 AM
#1
Thread Starter
Junior Member
Can I write in a FlexGrid?
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.
Last edited by Jethro Tull; May 11th, 2005 at 11:06 AM.
-
May 11th, 2005, 11:06 AM
#2
Re: Can I write in a FlexGrid?
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
-
May 11th, 2005, 11:22 AM
#3
Thread Starter
Junior Member
Re: Can I write in a FlexGrid?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|