hi! i in the midst of a project and i am stuck.
i have 2 queies:
1) i want a control that would look like a text box, i.e, have several typed lines in it, and clicking on any particular line will select the entire line. is there any control or object already present, or do i have to create one. if i have to create, how would i go about it...... please help.
Seems as though the simplest thing here would be to use a listbox. But if it must be a textbox, you could use a standard one and code the selection yourself. Try this simplified sample...
-
Private Sub Text1_Click()
-
Static Busy As Boolean
-
If Not Busy Then
-
Busy = True
-
Text1.SelLength = 3
-
Busy = False
-
End If
-
End Sub
-
The idea of the Busy thing is to prevent your code from getting into a loop by triggering the same event that you're processing. The highlighted line (setting SelLEngth) is the simplified part - it just selects the three characters starting where you clicked, to illustrate the idea. At that point, you could scan backward/forward through the text to determine where the current line starts and ends, then set the selection (
.SelStart &
.SelLength properties) to highlight part of the text.
2) is there any way to change the background color of only one line in a rich text box. if yes, how?
I suspect not, but will leave this for someone who has more experience with the rich text box. Have you tried selecting the appropriate part of the text and then changing the property?