How to bold a RichTextBox through button click? - wpf

The code I am currently using to bold the text currently is this:
rtb.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);
but the drawback of this having to highlight the text first before the bold can be applied.
Is there a way to make the next typed text in the RichTextBox bold without having to highlight and select text?

if(rtb.CaretPosition.Parent is TextElement)
{
(rtb.CaretPosition.Parent as TextElement).FontWeight = FontWeights.Bold;
}

Related

Text Editor with Color input in react js

How to get a input like this using text editor and not to have a tool box in it.
I want input with different highlighting colors

How to remove these blue bars/borders in checkbox in Kendo

I am creating a treeview using
kendo.data.HierarchicalDataSource
I want to remove these highlighted border. It is there only when using treeview.
Thanks.
Try overwriting the following style using !important. I overwritten it with red color, you can change it to any color of your choice.
.k-state-selected,
.k-state-selected:link,
.k-state-selected:visited,
.k-tool.k-state-selected
{
color : #ffff;
background-color:#ff0000!important;
}
Sample dojo

Codename One multiline Picker?

is there a way to display the selected text as multiline in a Picker component ?
The Picker component extends from Button and it doesn't seem to be a simple way to display the text as multiline.
You can clone the Picker class and call it something like CustomPicker that extends SpanButton instead of Button.
You only have to change Button to SpanButton.
SpanButton is a container that has TextArea in it to display multiline text.
Take note of setUIID() that behaves differently with SpanButton and applies the uiid to the container and not the text. Call setTextUIID() to apply uiid to text.
Although this will show the selected string as a multiline text, you shouldn't expect a multiline display of options in the Picker Dialog that popup. It is platform dependent and controlled natively.

SWT Combo with only dropdown arrow shown

I am looking for a SWT Combo where only dropdown arrow is shown in order to save space.
I found that setting a GridData.widthHint to the width of the arrow icon on the Combo might do the trick.
The question is how do I ask the Combo layout the exact width of the down arrow on the Combo so that I can set that as the widthHint?
Update:
Looks like even setting the widthHint = 0 still shows part of the text field. So any other ideas would be welcome.
I don't see a way to get the drop down button width. Messing around with the width hint is likely to be very platform dependent.
An alternative would be to use code similar to the CCombo control but without the Text field. This uses a Button with the SWT.ARROW | SWT.DOWN style:
Button button = new Button(parent, SWT.ARROW | SWT.DOWN);
When the button is pressed an SWT List control is displayed.

Font dialog and applying to TextBox text

How to apply a specified font style selected in a font dialog to a text box in visual basic.
I'm trying to implement a notepad program that provides the ability to choose the desired font (from a list of available fonts), and then I want to apply this font to the text in the TextBox.
I have done this so far
FontDialog1.ShowDialog()
TextBox1.Font = FontDialog1.Font
But it didn't work.
You would have to set all Font-related properties of the TextBox from the System.Drawing.Font that is returned by the FontDialog.Font property:
System.Drawing.Font font = fontDialog.Font;
textBox.FontFamily = new FontFamily(font.Name);
textBox.FontSize = font.Size;
textBox.FontWeight = font.Bold ? FontWeights.Bold : FontWeights.Regular;
textBox.FontStyle = font.Italic ? FontStyles.Italic : FontStyles.Normal;
See also this question.

Resources