al4629740
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
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?
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
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?
ASKER
I like it.
Is that the only way to do it?
Is that the only way to do it?
ASKER
In your example you use an MSHFlexgrid but I use an MSFlexgrid. Are they basically the same?
ASKER
Also, how do I restrict the textbox to be used only on column 10?
I can't think of any other way.
ASKER
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.
ASKER
Ok
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
ASKER
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 cellYes but you should ask a new question for that.
Never mind, I see the new question.
Project1.zip