Want to write in FlexGrid
How I can input my entry/write my values in a FlexGrid as I can do that in textbox ?
I want to input my values in database from FlexGrid column. and users of my application want to write the values in FlexGrid rather than textbox or other input tools?
Did you understand my problem ? How I can solve it ?
Rajib
Re: Want to write in FlexGrid
Flex grid cannot natively be edited by a user.
We use a trick of floating a textbox onto the cell that is clicked on.
Search the forum for "flxinput" - you will find threads and posts by me relating to this.
MartinLiss also has other tricks for allowing edit of a cell - not as robust as a textbox, but gets the job done. I believe he has links to this in his signature - find a post by him to follow that idea.
Re: Want to write in FlexGrid
I agree but you may try this:
(You'll need a Flaxgirs and a textbox to do this)
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
Note: I did not make this, I found it but it may be what you want.
Cheers,
RyanJ
Re: Want to write in FlexGrid
That is very similar to our technique - nice.
The problems always arise with how to handle to odd aspects - like scrolling and moving the textbox - or as you chose, removing the textbox on scroll.
Validation of textbox data is always an issue as well.