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

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

Related

Color of selected text in RichTextBox

In CSS we're able to edit the text selection's colors by using the ::selection pseudo-tag. Is it possible, to overwrite the default background color of the selection just for one control, e.g. a RichTextBox? I know, that there is no way to change the default behaviour by something like CSS, but at least overwrite it for this control might be possible.
I already googled for about an hour now, but I only found snippets of syntax highlighting. I want the text to be e.g. yellow instead the typical Windows blue.
EDIT
Like in this fiddle: http://jsfiddle.net/W99Gt/
In WPF you can accomplish this as follows:
myRichTextBox.SelectionBrush = System.Windows.Media.Brushes.Yellow; // WPF
myRichTextBox.IsInactiveSelectionHighlightEnabled = true;
Unfortunately, the desired behavior is not possible in Windows Forms (details here). The workaround would be to use a WPF RichTextBox in the Windows Form through ElementHost.
References:
TextBoxBase.SelectionBrush Property (WPF)
TextBoxBase.IsInactiveSelectionHighlightEnabled Property (WPF)
EDIT: Removed the WinForms solution, because SelectionBackColor does not provide the desired behavior.
There is a property RichTextBox.SelectionColor which should do the work. Quoting MSDN
A Color that represents the color to apply to the current text
selection

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.

Is it possible to have differently colored lines in multiline text box?

Is it possible to have differently colored lines in multiline text box?
I'm adding data to the text box and I want to clarify for the user different types of text by color.
How to do this if it's possible?
You can do this if you use a RichTextBox control. See the documentation here (particularly look at the Remarks and Examples sections). The standard TextBox does not offer this capability.
The standard Winforms textbox does not have this ability (and adding it would be troublesome).
You could look at using the System.Windows.Forms.RichTextBox as an alternative for this or one of the many commercial alternatives.
So depending on how you want the output, there's an browser/html control (basically a box), that you can pass a URL or a string of HTML, depending on what you're doing, you might want to use the RickTextBox - which has formatting commands - you could use regular expressions, or the offset of the text and then use a "set color" command on the text box with an IF structure.

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

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.

Selecting contents of Label Control

I have what I consider to be a pretty unique problem here, and no idea how to implement. From what I've seen, there is no documentation, tutorials, samples and/or articles on this. I've spent weeks researching, with nothing to show.
The problem:
I need the user to be able to select the contents of a Label Control at runtime, and edit it.
If this can be done by extending the existing Label control, great! Or, if this requires a whole new Label Control to be created, fine. So be it.
Using a TextBox is not an option I'm afraid.
Any help at all is greatly appreciated!
Thank you,
jase
If it's just because a look & feel issue you can make a TextBox control look the same as a label would looks like (just guessing since I can't imagine any reason for not using a TextBox).
Could you pop up a window with a text box in it and then have them edit it there, then set the text property of the label based on the edited text box or do you need to edit it in place? You can set the label text at runtime, but for user input you will have to use a text box.

Categories

Resources