Dumb question but I can't quite figure it out. How do I set things so that when I click on a cell in MSFlexgrid I can
1) edit it
2) detect changes:confused:
Printable View
Dumb question but I can't quite figure it out. How do I set things so that when I click on a cell in MSFlexgrid I can
1) edit it
2) detect changes:confused:
Edit it?
Simple version...
Me.text1.text = me.msflexgrid1.textmatrix(me.msflexgrid1.rowsel,me.msflexgrid1.colsel)
if you want to edit a cell (like it was atextbox) then search vbworld for
'flexgrid' you will find the code to pulldown a textbox over a cell
I just want to enter numbers and text in the cells just as I would with an excel sheet and trigger an event so that can save them as I go. I searched before I posted and couldn't find anything suitable.
yes i found code
search this forum for 'msflexgrid'
it gives you the reference in MSDN
both code examples are poor, and dont do what I want...
I am going to troll the net for a better control.. will reply later if
i find anything
Ok I found this http://support.microsoft.com/support.../Q241/3/55.ASP on MSDN but it seems very cumbersome. Anyone got any idea how to trigger an event just by clicking on a cell?
This does it
Quote:
MSFlexGrid1.Text = InputBox("Enter new value", ,MSFlexGrid1.Text)
Try this:VB Code:
'=================================================== 'Put this code in MSFlexGrid Keypress Event '=================================================== Private Sub MSFlexGrid_KeyPress(KeyAscii As Integer) With MSFlexGrid Select Case KeyAscii Case 8: 'IF KEY IS BACKSPACE THEN If .Text <> "" Then .Text = _ Left$(.Text, (Len(.Text) - 1)) Case 13: 'IF KEY IS ENTER THEN Select Case .Col Case Is < (.Cols - 1): SendKeys "{right}" Case (.Cols - 1): If (.Row + 1) = .Rows Then .Rows = .Rows + 1 End If SendKeys "{home}" + "{down}" End Select Case Else .Text = .Text + Chr$(KeyAscii) 'write your own keyascii Validations under 'commented lines Select Case .Col Case 0, 1, 2: 'if (your condition(s)) then 'accept only charectors 'Else ' keyascii=0 'End If Case Else: End Select End Select End With End Sub
It works- very clever;) - actually cleverer and more to the point than the MSDN example!
Thanks Hack