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.
Related
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;
}
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.
I have an EXTJS TimePicker control. I want to add a border around the picker box itself, not the label or overall panel just the box when the user clicks in the field. I have the follow code the provides a partial solution. It used to work when the label was to the left of the control. Once I moved the label to the top I get the incorrect behavior:
function txtTimeCtr_Focus(sender, event, eOpts )
{
//Change the border color to red to show the time is no longer running
sender.getPicker().pickerField.getEl().addCls('txtTime-focus-border');
//sender.getEl().addCls('txtTime-focus-border');
}
Here is a screen shot of what I am currently receiving
:
This is the functionality I need to obtain:
Thanks in advance everyone.
You need to set the style on the triggerWrap:
var f = new Ext.form.field.ComboBox({
renderTo: document.body
});
f.triggerWrap.setStyle('border', '1px solid red');
I am currently working in the C# windows application with DevExpress controls.
Now I want to change back color of bar button item while loading the form.
I've tried following code:
barButton.Appearance.BackColor = Color.Red;
but the bar button back color not changed to red.
By default, bars use the skins to draw their content. In this case, all background colors are provided by specific skin elements, which cannot be changed. The only way to change a specific item's background color is to disable skins:
put the BarAndDockingController component onto a form, and assign it to the BarManager.Controller property. Set BarAndDockingController.PaintStyleName or LookAndFeel to any non-skin style(for example "Flat"). Then use the Bar.Appearance.BackColor property to set the desired color.
Alternatively, you can create your own custom barItem in a way similar to the one described in the How to change the background color of highlighted links KB article.
I have a Image path(some thing like this "http://ABC/XYZ/PQR.gif").And I want to assign this image to checkbox in winforms using C#.winfroms checkbox does not have SRC,How can I assign this image to checkbox.?
The Background of a check box can be filled with a provided image.
See
CheckBox Overview
CheckBox Members
Control.BackgroundImage Property
Try this
Set the BackGroundImage Property.
Change the BackGroundImageLayout
Property to stretch.
Change the Font Color if required