Jump to content

RichTextBox Bullet Problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
eagleearth_ap

eagleearth_ap

    Newbie

  • Members
  • Pip
  • 8 posts
Hello everyone,

Is there a way to create a new line without causing the bullet to change colour. I have a bullet followed by a coloured text, but when I do Environment.NewLine it will change the bullets colour (which was originally black). Is there a way to fix this?

And here is the code which I am currently using for Eagle Earth, which shows the text when it sends or receives a message in a conversation.

           private void PrintText(Contact c, TextMessage message)

           {

               if (ConvoChat.Text != string.Empty) ConvoChat.AppendText(Environment.NewLine);

               if (lastsent != c.Name)

               {

                   ConvoChat.SelectionBullet = false;

                   ConvoChat.SelectionColor = c.Mail == _conversation.Messenger.Owner.Mail ? Color.Blue : Color.Black;


                   if (_contact.Status != PresenceStatus.Offline) ConvoChat.AppendText(c.Name + " says:" + Environment.NewLine);

                   else ConvoChat.AppendText(c.Name + " (" + DateTime.Now.ToLongTimeString() + ")" + " says:" + Environment.NewLine);


                   

                   lastsent = c.Name;

               }

               

               ConvoChat.SelectionBullet = true;

               ConvoChat.SelectionColor = message.Color;

               ConvoChat.SelectionFont = new Font(message.Font, 10f);

               ConvoChat.AppendText(message.Text);

               ConvoChat.SelectedText = string.Empty;

           }


Thanks :)

#2
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
I guess you have to move the cursor to the next line.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#3
eagleearth_ap

eagleearth_ap

    Newbie

  • Members
  • Pip
  • 8 posts
What do you mean? Could you show a code example if possible?

#4
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
No idea how to do that in code, but it's like pressing enter in notepad. The cursor is that line that constantly blinks.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#5
eagleearth_ap

eagleearth_ap

    Newbie

  • Members
  • Pip
  • 8 posts
Thanks I got it, but is there to a way to add a new line programatically instead of using Environment.NewLine()?

#6
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
string textWithLines = "Line 1 \n Line 2 \n Line 3";

Use \n.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#7
eagleearth_ap

eagleearth_ap

    Newbie

  • Members
  • Pip
  • 8 posts
Thanks I tried it but it didnt work with the RichTextBox.
When I press enter after the line, it didn't change the bullet colour, but when I do this:

if (ConvoChat.Text != string.Empty) ConvoChat.AppendText(Environment.NewLine);

This will, so I'm not quite sure.

#8
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
if (ConvoChat.Text != string.Empty) ConvoChat.AppendText("\n");
This works?
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#9
eagleearth_ap

eagleearth_ap

    Newbie

  • Members
  • Pip
  • 8 posts
Nope it still changes the bullet colour even after that.

#10
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
Apparently you can't use anything else in RTF.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#11
eagleearth_ap

eagleearth_ap

    Newbie

  • Members
  • Pip
  • 8 posts
I've fixed it a bit but it is still a problem when I type a first message and then type another which turns the first line into a coloured bullet. The rest remains black. I have added this code at the moment:

               ConvoChat.SelectionColor = Color.Black;

I put this at the end of the code at the 1st post.