How do I change the appearance of some text in a textBox? - c#

I'm building a program similar to Messenger, sort of a chatting software.
I created a textBox to display the conversation log, and I want to make it look like this:
Nick1: Hi.
Nick2: Hello.
How do I make part of the text bold?
I also want to allow users to change their own font, font-color and so on...
Thanks in advance.

Use RichTextBox if building a Windows Forms or a WPF app.

The best way is to use a RichTextEdit control, this control can take RTF format codes to easily format the text the way you want it.
eg.
\pard\plain\ltrpar\f0\fs14\sl240\slmult1\b\ Nick1.\par
\pard\plain\ltrpar\f0\fs14\sl240\slmult1\Hi
will show up as Nick1 Hi

Assuming you're using WPF I'd use an ItemsControl to display the conversion. Then for each item I'd have a couple of TextBlocks one for the user name (which would be bold) and the other for the message.
Hope that helps.

Related

Message Box Buttons Name Change possible in C#?

I need to change the Message Box Buttons Ok and Cancel Text to Update and AddNew?
Is it possible in C#.NET or I need to create a form and customize it?
Kindly help me in this.
The MessageBox class does not provide you with option to change the button text. This codeproject article, Localizing System MessageBox allows you do that by simply adding and using the class in your project
It is possible using a MessageBoxManager.dll, which you can get in the following link,
http://www.codeproject.com/Articles/18399/Localizing-System-MessageBox
You cannot change the text in MessageBox Buttons.To implement the scenario you can have your custom message box.Which can be build using User Control and show it as a Dialog whenever needed.
Changing the text of a button on a MessageBox is not possible by default. While the text might be changeable through fake localizations, this does not seem like a good way to do it from my point of view. I encourage creating a separate form.

Windows Phone Search box Tags on tapping search results

Is there any library available for Windows Phone with the tags in a search box feature? So if I start typing age, the search box should predict agent and agent smith etc and on tapping the predicted results, the search box gets filled with the tags (example image attached). Handling events like, backkeypress highlights the tag and another backkeypress removes the tag etc. Predicting results is easy, what I am looking for is all the events handling for search box with tags. Any free/paid library for the same?
There are a few AutoCompleteBoxes (Telerik, Windows Phone Toolkit), but the just work for one item. If you want more items, you need to create the control by yourself.
A lot of third party controls are available but you should prefer to write your own control. I used http://wpfactb.codeplex.com/releases/view/42340 control but you have to customized it and bugs are there to be fixed .
So I will suggest you to get hint from this and write your own control.
For something as specialized as this, I would write it myself. And XAML suits really well for such tasks.
One horizontal stackpanel with custom styled buttons being added, and one LongListSelector for the results.
This is very simple to implement.
Set the InputScope in your textbox.
On typing , you will get the possible result.
When you tap on the respective suggestion, you will get the value.
Create a Grid or Stackpanel and create a ellipse which should hold the tag value.
On tap of the value, add the value inside the created ellipse.

What WPF control should i use for my window?

So im making a WPF project where one of my windows has to let the user see a text. Select parts of this text for being put into an array of strings and no more than that. So he/she musnt be able to edit anything in the text only highlight parts and then click on a button. What WPF control would be smart to use for this?
I'd probably just use TextBox with IsReadOnly set. The various selection properties are all you need after that.

Font-Styles, ToolBox to use in C# for TextBoxes - Text

I'm searching a script or a toolbox in C#, where
the User can change his own Textstyle, after or while writing in a TextBox..
Just like here I can change the style:
BOLD
Text
And change Colors, TextSize and and and..
Hope u can show me a link or something similiar
As per my comment look at the RichTextBox
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx
You might also want to look at this:
http://www.digitalrune.com/Products/WindowsForms/TextEditorControl.aspx
This is an open source control for text editing and you would be able to look at the code I think

List of Strings to Links

i was wondering if it is possible in c# to set to a text box a list of strings that are clickable links? at the moment i can set the text box like this
txtBox.Lines = values.ToArray();
ideally though i would like them as links if possible? maybe link labels or something?
(I'm assuming you're using Windows Forms; the answer for WPF/Silverlight may be slightly different.)
A textbox just contains text - it's not "rich" enough to have links.
If you want a list you might want to consider using a ListBox of some description - or possibly a RichTextBox; I haven't tried creating links in a RichTextBox, so I don't know whether it's possible.
Of course, you haven't specified what you want to happen when the user clicks on the links, either...
Use RichTextBox and check this - http://www.codeproject.com/KB/edit/RichTextBoxLinks.aspx
You can try using Windows.Forms.Controls.LinkLabel. It allows storing multiple links along with the text in it.

Categories

Resources