Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Change Backcolor Of A Selected Text In A RichTextBox Control


Hi,
Does anybody know if it's possible to change the backcolor of selected text in a RichTextBox Control?
very inportant... (forecolor does not help me)
Thanks,
Si.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
RESOLVED-Setting The Backcolor Of Selected Text In Richtextbox-highlight Text
Does anybody know how to change the backcolor of selected
text in a richtextbox. Not the background color of the whole richtextbox only the selected word-lines !

I use a richtextbox which uses some validation and if there is an error in the text i want to display the word in red backcolor.

do you have any tips of alternatives if i cant do this?
Moreover how do you underline the selected text.
i use rtf.selunderline but it does not work.

thanks

p.s. i search the forum and did not find any solution.

Wanna Know How To Change The Backcolor Of The Selected Text
just like notepad.exe,the default color is blue,the richtext box is black,and ultraedit.exe can change its background color of selected text freely. Can we change it through API or some way else?

Rich Text Box Control (RTB Control). Giving Backcolor To The Selected Text.
Really simple question (I really should know this but to be honest...I just never deal RTF codes or ever had to learn them). I just want to be able to give a backcolor to the currently selected text.

In general, I already have code that is color coding HTML/ASP for me in my HTML Editor but I want to be able to give the Yellow back color to the <% tags just like other editors do. I just feel dumb that I cannot figure it out. I got all the forecolor parts working using .SelColor = g_ASP_COLOR.

Code:
<%
'sample asp
%>


Pretty much just like this but in the RTB not HTML.



Clint LaFever (aka: DaVBMan)

Possible To Change Backcolor Of First Two Lines In Richtextbox?
Is it possible to change the backcolor of only the first two lines of a richtextbox?

Backcolor Of Selected Text In RTF
I wonder:
Is't possible to change the backcolor of a certain selected text in richtextbox, like in Word!

ifso HOW!

Setting The Backcolor Of Selected Text In Richttextbox
Does anybody know how to change the backcolor of the selected
text in a richtextbox.
I use a richtextbox which uses some validation and if there is an error in the text i want to display the word in red backcolor.

do you have any tips of alternatives if i cant do this?
Moreover how do you underline the selected text.
i use rtf.selunderline but it does not work.

thanks

Change The Backcolor Of A Control................
Hi ,
I want to change the backcolor of a command button when I move the mouse over the button. Can anyone help me by either lending me some code or providing some url where I can find some examples for this ?

Thanks in advance,
Ramesh

Change Backcolor Of SSTab Control
How to change the backcolor of the tabcontrol. I mean really the tabs here, and not the background behind the tabs, which you can change with the backcolor property.

Any help would be appreciated.

How Do I Change The Backcolor Of A Treeview Control?
How can I change the back color of a treeview control in VB 6. It does not have the property 'backcolor' so i really have no idea.
Can anyone help me? thank you.

How To Change The TabStrip Control's Backcolor?
Hi All,

Please let me know how to change the tabstrip backcolor? Thanks in advance.

With Regards
Anees Ahamed.N

RichTextBox And Selected Text
Okay. I'm having another newbie issue here.

I have a rtb (txtNotepad), a combobox (comboFonts), and a second combobox (comboFontSizes).

The problem I'm having is that when I select some text and then change the font or font size, the change won't take effect until I click the highlited text back in the RTB. And if I change the font and/or font size then highlight some text, the RTB changes to the new font as I select the text. Can somebody tell me where my problem lies? I'd be happy to post some code if necessary. Thanks in advance!

Change Backcolor Of A Cell In Datagrid Control
Hello everybody,

I use VB6 on WIN XP. I would like to emphasize some cell in a datagrid control. I can access each cell but I don't know how to change the backcolor of just one cell.

Can you help me ?

Change BackColor Of A SPECIFIC Row In ListView Control
Anyone know how to change backcolor of a SPECIFIC row in a ListView control? I can't find out how to underline a specific row sow I am guessing it may not be possible.

Automaticaly Change BackColor Of Control When In Focus
Dear All,

Is there anyway to Automatically change Backcolor of Control when in Focus and Lost Focus without have to coding on ControlName_Gotfocus and ControlName_LostFocus?

Thanks for all of your help.

Regards,
Emi

Can I Change Each Cell Backcolor Of Listview Control ?
Can I change cell colors of listview?

In the Visual C++, I can do this with CustomDraw Method.

But I didn't found yet in Visual Basic.

If someone know how to change the cell color of listview, please answer....

Can I Change The BackColor For Standard Toolbar Control?
Hi,

Can I change the Back color for the Standard Toolbar Control ?

Regards

RM

Print Selected Text In Richtextbox
I apologize for asking for too much help this month.
I'm facing another problem print selected text in richtextbox. My code does not print selected text in richtext while the same code works fine in a normal textbox.

The code below does print any word selected in a normal textbox. I used this code to print a selected text in a richtextbox. It didn't print. It generated "Type mismatch" message for the ".SelText". What is the correct code for printing selected text in richtextbox?

' Code to print selected text
PrintNotes Text1.SelText ' Prints fine for normal textbox.
' Code below generates "Type mismatch" error for "SelText".
PrintRTF RichTextBox1.SelText, AnInch, topSpace, AnInch, AnInch

Any help will make my life easier. Thank you.
MydanVue

Problem With Selected Text - RichTextBox
y0,
In my app the user can cut, copy and paste text.
I want the Cut button to be enabled only when the user is selecting a text (with Shift), and if the user is not selecting anything i want the button to be disabled.
I've tried this:

VB Code:
Private Sub EditText_Change()If Len(EditText.SelText) > 0 Then    Toolbar1.Buttons(11).Enabled = True    Toolbar1.Buttons(12).Enabled = TrueElse    Toolbar1.Buttons(11).Enabled = False    Toolbar1.Buttons(12).Enabled = FalseEnd IfEnd Sub

How can i do that?

Printing Selected Text In A RichTextBox
I am trying to print selected text or the entire page if nothing is selected. but for some reason the "SelText" Property is retaining the text and when I set it to "" it clears out the text that was selected previously in the RichTextBox.


here is the code:



Code:
Private Sub Command1_Click()

If Not RTFPrint.SelText = "" Then
Printer.Print RTFPrint.SelText
Printer.EndDoc
Else
Printer.Print RTFPrint.Text
Printer.EndDoc
End If
RTFPrint.SelText = ""
End Sub

RichTextBox - Save Selected Text To File
I thought this would be easy ... but ...

I want to select some text from a RichTextBox control, and then click a command button to save the selected text to a file. Es posible ?

Change Selected Text Color
I dont want my text hilited blue, can you change that?

Need Help Text Boxes (change Selected, (MOD-Utilitie))
Hello Everybody,

I want to make a MOD-Utilitie for a game, which makes it easyer for ppl to change units abilities and stats. I'm making this by loading the ini files and now the prob comes I want to make soemthing like, every stat has a different text box where the user can change the stat of, like speeds = text1.text and health = text2.text, but the ini files kind of looks like this:

[Barracks]
Health = 200
Cost = 200
Buildtime = 50

[Soldier]
health = 10
Cost = 50
Buildtime = 10
Speed = 5

And here is the real prob, I can search true the field and select things, but how can I get the health of the barracks in text2.text, is there some way I can say,


Code:
dim stat as string
stat = "Health = "
StartPoint = instr(1, ini-file, stat)
Startpoint = (startpoint + len(stat))
and then I have the start point for the selected text, and is it possible to make the end point the place were the enter is...(the place were the line ends)
(I was also thinking while writing this thread, if I just continue like this:
endpoint = instr(startpoint, ini-file, " ")
then it would select until the first empty space, which is the end of the thing we want to change, but maybe you guys have better ideas???)

and know the last probs how can I put the selected text into a textbox???
and how can I afterward put the textbox text in the place of the selected text???
and the last question, maybe a stupid one, but I couldn't really find it on the forum, when I'm ready changing the stats, then I must save the (edited)ini-file, how should I do this???(I never learned how to save text files)

Listbox: Change Text Of Selected Item
hi all,

just wondering if anyone knows a way of changing the text of the selcected item in a list box?

for example: if i have a listbox with the following list items:

one
two
three
four

and "two" is selected, and i need to change its text to "this one".

i would like to avoid regenerating the list by clearing it and adding all the items again if possible.


thanks for your time and consideration,

mojoinst

Change ComboBox Text When Item Selected
I though this would be easy, I have a ComboBox style set to 0, and the list is populated from a dB. What I want to do is have the default Text change to the selected item when the list reloads. Here is the code;
Code:' Populate the Type list
    cboEntryType.Clear
    If Len(sqlQuery) > 2 Then
        cboEntryType.Text = sqlQuery
    Else
        cboEntryType.Text = " All"
    End If
    
    For i = 0 To m_TypeRows

    str9 = " " & m_varTypes(0, i) & " " ' Entry Types
        cboEntryType.AddItem str9
    Next
sqlQuery is a parameter sent to another function that returns the ListItems, if I set a watch on the var sqlQuery it does indeed have a valid value, but when the box is displayed the Text is " " with focus on the box.

Change Color Of Selected Text In A Listbox
I'm trying to add text to a listbox and have different text be different colors to represent either an open or closed file to match some other software we currently use. Does anyone know how to change the text color inside a list box. I will need to be able to use 3 different colors.

Thanks in advance for any help.

Textbox -- Get The Selected Data, Change Color Of A Bit Of The Text?
Hi
I was wondering if I could do the following :

1. see what I selected in a text box (I would do like a loop and check what is selected, but I have no idea on how to retrieve the selected text)

2. Can I do a textbox that has bits of it written in diffrent colors?
Like couple of letters in red, others in blue and so on.

Thanks!

Change Color Of Text In Richtextbox
I'm using a richtextbox as a regular textbox (I'm not doing any formatting). I'm using a rtb because it can handle much more text than a regular textbox.

But there's no setting to change the color of the text like in a regular textbox.

So, how would I go about changing the color of the text?

I'm just using it like
richtextbox1.text = "text string"

Thanks,
John

(? Help) Change Listbox Selected Text Without .additem Or .remove Item
Hi, I browsed through posts and didnt see this question elsewhere so I hope I didnt miss it if it was answered already. If so im sorry.

I was wondering if there is anyway to change the selected text entry for a list box without adding or removing an item.

Example: If there were these options in a list box:

A
B
C

and "B" had been selected by the user is there anyway to change "B" to "D" without using the .additem or the .remove command? If you need me to restate or clarify what im asking please let me know and Ill repost as soon as I see it. Thanks for any help I get in advance.


- Sidenote: I would use a loop and simply add them into another list box and back into that one in a different in the correct order but theres some sticky and touchy coding done on the list box's _click statement that really wouldnt make such a loop possible....if this sidenote didnt make sense sorry its 5 am .

Change Mouse Pointer For A Particular Text In RichTextBox
Is it possible to change the mouse pointer when I place the mousepointer over a particular text in RichTextBox.

For example, if the text is like this

"see the site www.yahoo.com for details. "

If the move the mouse pointer over www.yahoo.com, the mouse pointer should change into hand icon.


Raja Pandian

Change RichTextBox Fonts Of Specific Text.
Ok
I have some text in my rich Text box that I need to format. Whats the best way to do this through code?

Whats the code to set the RichTextbox's Scrollbar to the bottom? I had it a while back but I've lost it.

Thanks in advance.

Flexgrid , Change Merge And Change Backcolor Cells
Hi

I need Merge some cells in flexgrid , after change backcolor from cells merged


tks

Backcolor Problem In RichTextbox
When I save the contents of a RichTextbox which contains text with different colors and a backcolor other than white, and I open it again afterwards, the text forecolors is OK, but the backcolor is always back to white.

Richtextbox Backcolor When Disabled
I need to change the backcolor of a disabled richtextbox so it looks like a black block(with white letters), but since it is disabled, the backround is light grey, even when the backcolor property is black.

Thanks in advance
 

How To Set Backcolor For A Single Line In A RichTextBox
Is it possible to set the Backcolor for a selection of text in a
RichtextBox, something like .SelBackColor for example?
TIA

Check For Selected Text In A Webbrowser Control?
How can I check if the webpage loaded in the webbrowser has any etxt selected in it, and if YES then retrive the text??

please let me know.

basically I am trying to do this

if Screen.ActiveControl.SelLength <> 0 then
'Enable the copy function
'Get the selected text
else
'disable the copy function!
end if

This code works for a normal textbox but not a webbrowser, anyone know what I can do??

How To Set The Colour For Selected Text In Webbrowser Control
Hi all,

Anyone know a reliable way to set the colour of selected text in a webbrowser control whilst in designmode? (NOT fgColor of entire document)...hmmm....some TT fontnames passed don't stick either unless sent from a commondialogue but then the colour selection is ignored - AAARGH!


I'm using mshtml.tlb and webbrowser control in vb6

 

Edited by - scott_p on 9/22/2002 3:52:56 AM

Capture Selected Images And Text From Webbrowser Control
I've got a webbrowser control on an Access form and I need to capture only part (one table) of the webpage displayed.

I need to grab images too, ie to mimic selecting some text and images with the mouse and using copy and paste.

Does anyone know of a way of doing this? I've seen many posts on this and other sites about selecting text only, but nothing about grabbing images too.
it seems to me that this should be a realtively straightforward operation, maybe I'm missing something really obvious.

As an example, I want to grab a copy of the current list of .NET forums displayed on www.vbforums.com and save it in a Word doc (see attached) and keep the images.

Any ideas gratefully received, before I get completely fed up with manually cut'n'pasting....

Modifying Text In A RichTextBox Control
Why can I not do the following:

Mid(RichTextBox1.Text, RichTextBox1.SelStart + 9, 1) = "+"


I get the following error if I attempt to do so:

Compile error: Variable required - can't assign to this expression


Is there a way for me to programmaticaly modify the contents (text) of a RTB in a program sub or function?

Appending Text To A RichTextBox Control
1.] How can I append a formatted text to a RichTextBox
Control? I've used the .TextRTF property but it seems not
working. Here's what I did:

RichTextBox1.TextRTF=RichTextBox1.TextRTF+RichSamp.TextRTF


2.] How can I append a Text in the RichTextBox without
referencing to the entire text. If you use

RichTextBox1.TextRTF=RichTextBox1.TextRTF+RichSamp.TextRTF

you are actually placing the entire text of the
RichTextBox1 to the memory... right? What if my
RichTextBox contains 500kb of text or more? Can I not have
a pointer and points to the end of the text and place the
text (formatted) right there without touching the other
texts?

Text Position In Richtextbox Control
Hi Guys. I have spent the last few hours searching the internet trying to find out how to enter a string into the richtextbox control and have it display the string in the bottom left corner and stay in that position even if the form is maximised. Any subsiquent strings will scroll the control up.

Any ideas how to do this would be much appreciated.



Edited by - Gomjibar on 8/21/2004 7:05:43 AM

Border Around Text In Richtextbox Control
Hi,

Can someone please tell me how can i put a border around text in a richtextbox control using the PARAFORMAT2 API Structure?

Thanks

RichTextBox Control Text Hilighting
Can somebody help me? Here's a scenario. The following text is in a RichTextBox:

1. This is a sentence numbered one.
2. This is another sentence numbered two.
3. This is a short number three.

I need to be able to move the mouse over either of the three sentences and have that sentence select itself by hilighting, underlining, something of the sort (like a hyperlink) so that when a user clicks it, I can transer the data into another dialog box.

If a MouseMove event is not possible or whatever, can someone show me how to do this by clicking somewhere in the sentence?

(Recap: If someone clicked or moved the mouse over the word 'short' in sentence #3 above, then the sentence would be hilighted from the beginning of the number "3" to the period after the word 'three.') Keep in mind some sentences will wrap more than one line of text.

Thanks in advance if you can help me....

RichTextBox Control Dynamically Chagnig Text
hi there

Does anybody know how to change the text colour of the RichTextBox not by the way of selecting it then changing it.

Here i'll explain, Lets say i was sending some data though my winsock control and gave this data to the parser, so lets say again when the parser found the substring of ":End", I would change this to blue lets say.

I thought i could get an idea of how to do it by changing the colour etc and saving the file rft format.

heres the file:


Quote:




{
tf1ansiansicpg1252deff0deflang1033{fonttbl{f0fnilfcharset0 Arial;}}
{colortbl ;
ed0green255lue0;}
jason cf1 Howellscf0 washere
par }




All this does it changes "Howells" to green, but when i tried to put this into the control again eg. RichTextBox.text it printed the code and did not convert it back again to green.

is there a way around this??

the pig..

How To Create TWO COLUMN TEXT In RichTextBox Control?
dear sir,
i am trying to develope a project in VB6 with Richtextboxcontrol which contains a page with TWO COLUMNS (in RTF format). i tried with "cols2colsx720linebetcol" tags of RTF format, but i can not succeded. Please help me in this regard.
with love,
r.rajasekaran

RichTextBox Control - Limit Text To Size Of Box
Can this be done? I can't find a way to limit the amount of text entered into a RichText control to what will fit in the viewable box. Any ideas will be greatly appreciated. Remember, RTF allows multiple fonts and sizes, so the MaxLength parameter won't work. Thanks.

RichTextBox - Paste Formatted Text, Not Control Code!
Hello,

I've been at this for an hour or so now... What i'm trying to do is the following...

I have:


Quote:





MyRTB < - Rich Text Box
MyString < - normal string variable
Database Field <-MySQL TEXT type field







VERRRRY simple... I'm first storing MyRTB.TextRTF in the Database Field. Next, i retrieve that database field, put it into MyString , and then put that string into my rich text box using this code:


VB Code:
MyRTB.TextRTF = MyString


Again, very simple... but this isn't working!!!! i'm becoming quite frustrated. Everyone i talk to tells me that exact code works for them.... That exact code does not work for me... what happens is the control code is put into the text box instead!

So the string that should appear like this:

Formatted Text

Is pasted into the text box as this:


Quote:





tf1ansiansicpg1252deff0deflang1033{fonttbl{f0fnilfcharset0 MS Sans Serif;}}
{colortbl ;
ed255green0lue0;}
viewkind4uc1pardcf1ulf0fs17 Formatted Textcf0ulnone0
par }







Now, like i said, this is becoming very frustrating... by all means, it should be working!!! it seems like for some reason, storing it in the database in between is messing it up... i've tried using MyRTB.SelRTF = MyString, MyRTB.Text = MyString, and MyRTB = MyString ... nothing is working... however, when i paste the text to the clipboard, and put it back in a textbox with MyRTB.SelRTF = Clipboard.GetText() , it pastes in formatted just nicely...

So, that is why i'm led to believe it's the database that's making things mess up... any ideas? i've tried cstr() the variable already don't worry...

Passing Text And Format From Word To Richtextbox Control Using VBA
Hello,

I need to show formatted text from a document in a form. I have do the following:

· I read the document
· I save it as RTF
· Using a Richtextbox I open this new RTF file.

It works fine but it takes some time to show the information. This is the code

Code:Dim d As Document
Dim r As Range

RichTextBox1.Text = ""
Set d = Application.Documents.Open("c:Test.doc")
d.SaveAs "c:Test.rtf", Word.WdSaveFormat.wdFormatRTF
d.Close
RichTextBox1.LoadFile "C:Test.rtf"

Using VB.NET or VB6 is possible to use the Clipboard to do the same and work faster and is not required to save the file again. How can I use the Clipboard without losing the formats with VBA?

Best Regards

AlfredoDS

.backcolor Change
Can someone give me an example on how to change the backcolor of a label when i go with my cursor over it. I dont want it to go from blue to white but from blue to some lighter blue and again from some lighter blue to almost with and then white, that you see the color change from blue to white in a flow. I dont know exactly how to do this all i know that i need a timer with it.

How To Change Backcolor ???
Hi,

Does any one know how to change backcolor of datagrid control.Which takes by default windows color.Do i need API
to do this.

Any clue ....

Copyright 2005-08 www.BigResource.com, All rights reserved