Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

Highlight and edit a column in msflexgrid - vb6

This is what I am using to edit only one column in my flexgrid.  column 10

Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)

Dim sTemp As String

With MSFlexGrid1

sTemp = .TextMatrix(.Row, .Col)

If .Col <> 10 Then Exit Sub ' This might need to be 7
Select Case KeyAscii
Case 8 ' backspace
If Len(sTemp) > 0 Then
sTemp = Left$(sTemp, Len(sTemp) - 1)
End If
Case 27 ' escape
sTemp = ""
Case 0 To 31
KeyAscii = 0
Case Else
sTemp = sTemp & Chr$(KeyAscii)
End Select
.TextMatrix(.Row, .Col) = sTemp
End With

End Sub

Open in new window


The problem is that when I edit the column it begins at the far right of the data and then I have to delete each character one at a time in order to edit or replace the data.  Can I not be able to just simply highlight a specific word or portion and then just edit like I do in a word document?  How can I edit values simply by highlighting and editing?
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Here is a demo project that floats a textbox over the grid cells. It should help you do what you want. Note that the green color is just there for emphasis.
Project1.zip
Avatar of al4629740

ASKER

I like it.

Is that the only way to do it?
In your example you use an MSHFlexgrid but I use an MSFlexgrid.  Are they basically the same?
Also, how do I restrict the textbox to be used only on column 10?
I can't think of any other way.
How do I restrict it only to work in col 10
I'm about to go to sleep so I'll get back to you in the morning.
Ok
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
Is it possible to modify this code to simply view a paragraph within a cell.  Without allowing the user to edit the cell?  I asked another open question....
Is it possible to modify this code to simply view a paragraph within a cell
Yes but you should ask a new question for that.
Never mind, I see the new question.