473,785 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextBox format prob

I am writing lan chat program and want the messages to be color coded for
sent/recieved...you know the standard idea.

I cannot seem to get the richtextbox to keep the color. I do a recieve and
it is fine, I do a send and it is fine, another recieve and all of the text
becomes one color.

Here is the code I am using for the the Recieve..I use the same code for the
send.

Private Sub mobjClient_Line Received(ByVal sender As Client, ByVal Data As
String) Handles mobjClient.Line Received

Dim pstrmessage As String = Data
With txtRecieved
If .Text = "" Then
.Text &= pstrmessage
Else
.Text &= vbCrLf & pstrmessage
End If
Dim pintTextLen As Integer = Len(.Text)
Dim pintLoc As Integer = Len(.Text) - Len(pstrmessage )
Dim pintLen As Integer = Len(pstrmessage )
.SelectionStart = pintLoc
.SelectionLengt h = pintLen
Dim pstrSel As String = .SelectedText
.SelectionColor = Color.Navy
Me.Show()
End With

End Sub

I check the pstrSel and it looks like the corect text is selected, but the
selectioncolor seems to be changin everything. Am I just over looking
something here?
Nov 21 '05 #1
1 1219
remove this SelectionColor = Color.Navy and put it on top of ur block.
this how i do to prevent randon colour in chat. i do in in irc chat too
similar to mirc/pirch chat.
.SelectionColor = Color.Navy
If .Text = "" Then
\\
\\
\\
Me.Show()

hope this help'

Lespaul36 wrote:
I am writing lan chat program and want the messages to be color coded for
sent/recieved...you know the standard idea.

I cannot seem to get the richtextbox to keep the color. I do a recieve and
it is fine, I do a send and it is fine, another recieve and all of the text
becomes one color.

Here is the code I am using for the the Recieve..I use the same code for the
send.

Private Sub mobjClient_Line Received(ByVal sender As Client, ByVal Data As
String) Handles mobjClient.Line Received

Dim pstrmessage As String = Data
With txtRecieved
If .Text = "" Then
.Text &= pstrmessage
Else
.Text &= vbCrLf & pstrmessage
End If
Dim pintTextLen As Integer = Len(.Text)
Dim pintLoc As Integer = Len(.Text) - Len(pstrmessage )
Dim pintLen As Integer = Len(pstrmessage )
.SelectionStart = pintLoc
.SelectionLengt h = pintLen
Dim pstrSel As String = .SelectedText
.SelectionColor = Color.Navy
Me.Show()
End With

End Sub

I check the pstrSel and it looks like the corect text is selected, but the
selectioncol or seems to be changin everything. Am I just over looking
something here?


Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6551
by: Yuelin | last post by:
Hi there How can I read a RTF file into a RichTextBox control without the original format being lost? And how can I save the text entered in a RichTextBox into a RTF file without the original format being lost? It seems I can't use System.IO.StreamReader. Is there any thing I can use to do this? Many thanks
4
15916
by: Du | last post by:
I want to format the text within my richtextbox. However I have large amount of text to change, simply using richtextbox.select and format is not pratical. How do I change text format using control characters (ie rtf format string) ??? I only need a few formating string; font-weight, font-size, color, and font face
10
11664
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline = true richTextBox->Text = S"First line /n" richTextBox->Text = S"Second line" Thanks
0
2116
by: y2k692hu | last post by:
Hello I am trying to run this and I keep getting a "SystemNullReferenceException: Object reference not set to instance of an object" error. I have three menu items bold, italic and underline. When i select the text in my RichTextBox, in order to format it bold, italic or underline, I get that error. The debugger points to my Private Sub UpdateMenuItems - the first line of that sub ->where it says "If rtbMain.SelectionFont.Italic = True ".I want...
2
2891
by: AWesner | last post by:
I am currently working to create a VB program that will do more detailed in-file text search functions than windows has to offer. I have a form with a RichTextBox control to display the text that has been found in the files. The problem is that when a search has been found that is at the very start of the file and the .select method is used to select just the first portion it ends up selecting everything in the RichTextBox control...
3
7191
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to just add plain (e.g.. rtf.Text += "new stuff..."; ) but some text, when added, I want to be in a different color or font size. Find() will not work because the text will vary. I have delimiters on it so I could recognize it with a regular ...
3
5615
by: bero81 | last post by:
hi,i'm in a big prob! i'm sending e-mail with the ocx ansmpt,and the body text is a richboxtext. Now,the point is,the host receive my e-mails but the text of my e-mail is different because it's not formatted like the original i've sent... for example,i'm sendind: How are you doing? i'm fine and you?
1
11025
by: farrukhqadri786 | last post by:
Hi! I have an imageList and a richtextbox in a C# form. I want to insert image from imageList into a richtextbox. I have found the following code on net but it does'nt work. InsertImage(EmotionsImageList.Images); public void InsertImage(Image pic) {
0
3451
by: shivaranjaniadimulam21 | last post by:
Hello, I need to implement an email editor control in my application. The control should allow me to type in text in any format,font etc. This i have managed using the richtextbox control available with .NET. As the email textbox can include the embedded images I want to provide this functionality in it. Now the next stuff is I want to prepare an html file from this all the
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8979
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.