Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text back color in textbox 1

Status
Not open for further replies.

swetham

Programmer
May 5, 2010
257
DE
How to change the selected text backcolor in a textbox by pressing some key like (ctrl+K)?
 
Sorry , i need to change it in Richtextbox. I have used the following code,

rtbx.selectionbackcolor=color.yellow.

Now i needt to change the text in datbase with the color and retrieve it when the text is displayed.

How to save it in the datbase and retrieve the text with the color for a particular text?
 
You have to add a keypress listener to the form, there is a special setting for listen for enabling key presses(can't remember the property)

in the key down/up event you would have to inspect the keypressed event args, determine if the keys pressed were ctrl and k, then set the control.backcolor = Color.X

hth,
Lodlaiden

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
I need to change the textbackcolor of a particular selected text.
 
Store the RTF of the Richtextbox to database , retrieve and pass it to RichTextBox
simple example
Code:
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim str As String = Me.RichTextBox1.Rtf.ToString
        Me.RichTextBox2.Rtf = str
        MessageBox.Show(str)
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.RichTextBox1.LoadFile("E:\myRTF.rtf")
    End Sub

Zameer Abdulla
 
That means i should save the richtextbox data into rtf file in some server location & laod the file while retrieving. If that is correct, without saving hte file is it possible?
 
Not necessarily store a file. You store only the rtf to the database

Insert Into database
Code:
Dim strRTF As String = Me.RichTextBox1.Rtf.ToString
<Store strRTF to database>

Retrieve from database
Code:
Dim strRTF As String = <Data from database>
 Me.RichTextBox1.Rtf = strRTF

Zameer Abdulla
 
Near me.richtextbox1.rtf=strRTF i am getting the error that "File format is not valid.". I am usiong MYSQL datbase, i have saved the rtf format in datbase with dattype "Text", while retrieving th e text is retrieved to the string variable but while assigning the error is coming.
 
Sorry in MYSQL while saving i should replace some of the characters. Now it is working, but i have one doubt. While saving the text which datatype is suitable and what should be max field size.
 
I have never worked with MySQL. May be LONGBLOB or LONGTEXT

Seek some expert help.

Zameer Abdulla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top