I have created a text box in run time using XAML. I need to make the text box as read only. So I have used a code Browsable[True] & ReadOnly[True] to achieve this.
So now the style of the text box is changed. Initially, the data in the text box were in bold. But now it is bit lite not in bold text. Now how to make it as bold. Thanks much.
[DisplayName("Name"), Browsable(true), ReadOnly(true)]
Setting the textBox as readonly does change it´s design and once you have set it as readonly you cant modify it´s content. What about using a Label instead, the user cant modify a Label´s content ever and that´s bascically what you achieve by setting the textBox as readonly.
Adding the Browsable property to the read only property makes the text box as Read only while generated on run time in WPF.
[Browsable(true), ReadOnly(true)]
Related
Is it possible to change the forecolor of substring in element text in GridControls's Tileview in devexpress winforms?
What's going to happen is I have a textbox and tileview
In event while textbox textchanged fire, the text matched in tileview's element text will be highlighted
The initial color of tileview's text will be blue and if its match with textbox's text it will be highlighted as gray.
See picture to check the illustration:
Is it possible? or will i need another component to attain this output?
As far I can see there is property group called Appearance (TileView.Appearance) and there you have property called ForeColor. Moreover, you can acces via code by calling
titleViewName.Appearance.ForeColor = <RGB value goes here>
Finally, there is possibility for dynamic customization via event ItemCustomize.
For further information please check official documentation and DevExpress forum. There already existis questions similiar to yours.
You can try to use HTML Text formating for displayed string:
Text = "This is some <color=red>red or <color=black><b>bold</b> text!"
I'm using a Winforms ComboBox, specifying the background color and font programatically. I've also set AutoCompleteMode to "Suggest" and AutoCompleSource to "ListItems", via the designer properties.
Autocomplete seems to work great, but the drop down it displays for auto complete uses the Winforms default background color and font. I'd like it to match the background color and font of the rest of the control. Does anyone know how to accomplish this in .Net 4.0?
Thanks for your help.
AFAIK you cannot do this. Setting the background colour only affects the "TextBox" part of a ComboBox, i.e. when you are using a ComboBox in DropDown style (default) allowing the user to enter free text as well as selecting from the list.
In a very simple WPF application, I have the following code in the button1_click() method:
textBlock1.Inlines.Add(new Run("TextBlock is designed to be lightweight."));
canvas.Children.Add(textBlock1);
Debug.Print("textBlock1.Text: {0}", textBlock1.Text);
The Debug.Print statement prints nothing for the Text property, but the actual text (i.e. "TextBlock is designed...") is visible in the TextBlock control on the canvas. Why doesn't the Text property depict an exact copy of the Inlines?
PS: There is no data binding, etc. used. The project is very simple, with a TextBlock and a Button on a Canvas inside MainWindow, and minimal XAML; everything is handled in the code-behind.
You can just directly set the Text property of the Textblock. If you have a text that needs special formatting like bold, italic, underline, etc in for each words then that's the time you want to use the Inlines.
If you want to debug the actual Text you want to extract the Run into a separate variable and access its Text property.
var run = new Run("TextBlock is designed to be lightweight");
Debug.Print(run.Text);
C# WinForms: There is a lot of code playing around SelectionStart, SelectionText, etc properties of a textbox in a program defect I am working on. The thing is that I do not want the text of this text box to get highlighted with those selectionstart, selectionLength, etc methods....Is there a way that I can say turn off selection highlight when we are manipulating the text of a text box with those properties?
Kind of clumsy, but at the end of each of those event handlers you could put focus on some other object. Maybe a textbox that's not visible on the form?
I have a richtextbox, when I leave it for example to go to another panel where I want to manipulate the selected text I can no longer see the selected text. Is there a way to make it still show the highlight?
Set the RichTextBox's HideSelection property to false.