c# make textbox unselectable [duplicate] - c#

This question already has answers here:
How to change the font color of a disabled TextBox?
(9 answers)
How to make text in a WinForms TextBox unselectable without disabling it?
(3 answers)
Closed 10 years ago.
I want to get the same functionality as Textbox.Enabled = false; so that the text in a textbox is not selectable at all but without the text changing to light gray. It should stay the same.
Textbox.ReadOnly = true; still lets you select it so that's not good.
And no it has to be a textbox not a label unfortunately.

Is this in WPF? If so you should use Textbox.Enabled = false; and change the styling so that this disabled textbox looks the way you want it to look.

Related

Can i use mouse-click event as a function without human interaction ? So that whenever i call the function, it makes the control clicked [duplicate]

This question already has answers here:
How do you simulate Mouse Click in C#?
(7 answers)
Closed 8 months ago.
Suppose I have a ComboBox Control, in which there is dropdown button.
Now I have to open the list without using human interaction by default.
Can I do this ?
Use ComboBox.DroppedDown Property:
comboBox1.DroppedDown = true;

Setting width of ComboBox autocomplete [duplicate]

This question already has answers here:
Combo box drop down width on suggest
(3 answers)
Closed 2 years ago.
In the WinForms combobox, the width of the drop-down can be set programmatically, as in the following example, code and screenshot:
myComboBox.DropDownWidth = 300;
For the combo box, I have enabled the autocomplete:
myComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
myComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
The autocomplete drop-down appears as follows:
How can I set the width of the drop-down containing the suggested items?
I believe that is not possible. You'll probably have to create a custom control to achieve what you need.
Here some information that might be useful for you:
https://social.msdn.microsoft.com/Forums/windows/en-US/f88f37c9-95f9-4f2f-84b5-e262f49a009d/autocomplete-suggest-box-can-this-be-influenced?forum=winformsdesigner

How to set Vertical alignment to text in textbox control in Winforms? [duplicate]

This question already has answers here:
C# WinForms Vertical Alignment for TextBox, etc
(5 answers)
Closed 7 years ago.
I'm trying to align the text in the middle to my textbox control in winforms.I also increased the height of the textbox by setting the multiline property to true. But when editing the text, the text goes to the top-left position. I want it to be in the same position,even on edit mode and normal mode.
I want to achieve it like
Excel-Normal mode and Excel-EditMode.Is this possible? Thanks in advance.
What you're thinking of is a RichTextBox.
I forget if it supports vertical alignment, though I'm sure there is a work around.

Buttons in WinForms [duplicate]

This question already has answers here:
ToggleButton in C# WinForms
(12 answers)
Closed 7 years ago.
I'm currently working on some software in Windows Forms and I was wondering if there's any way to have the buttons stay in their "clicked" state? I want to use them like radio buttons so one would be "clicked" and the other normal, and will switch when the other is selected.
I've looked in the Button properties but I couldn't find anything
You can make checkbox or radiobutton look like a Button
cb.Appearance = Appearance.Button;

Change Colour of Group Box Group Title Name [duplicate]

This question already has answers here:
Change group box text color?
(5 answers)
Closed 8 years ago.
How I can change the GroupBox title colour?
The default colour is blue and I would like to alter that.
Try using something like the following:
groupBox1.ForeColor = Color.Red;
It should change to the desired color.
In WinForms - change the ForeColor property of the Group Box to the desired color.
Did you try setting the ForeColor property?

Categories