It seems that the Windows 10 style of Combobox looks disabled when I change it's DropDownStyle to DropDownList.
On the left is the Combobox before any user interaction. On the right is when a user clicks on it to open it.
Now, I don't like changing default design to something the user might not expect but to me the default design makes it look disabled and might confuse the user.
I've tried setting the control's BackColor to white but there was no change.
I want the behavior of DropDownList where the user can only pick from the options available and not write in a new option but the look of DropDown (a plain white background).
You can change the FlatStyle property and check which style is more desired.
It seems the Flat style is the style you are looking for. (based on your comment)
Flat: The control appears flat.
Popup: A control appears flat until the mouse pointer moves over it, at which point it appears three-dimensional.
Standard: The control appears three-dimensional.
System: The appearance of the control is determined by the user's operating system.
Also in the worst case you can set DrawMode to be owner draw and draw combo box yourself using DrawItem and MeasureItem events.
Related
Is there a way to make an entire WPF Window inert after a button click?
The window is invoked via Window.ShowDialog() and after use, the window is no longer needed for interaction but I leave it open to remind the user of the inputs in TextBox's, ListBox's, and give visual feedback via OxyPlot and so on. I leave it to the user to close the window manually.
One solution is to disable all buttons but that's tedious and it still leaves TextBox's functioning. That's not optimal because for anything to be functioning creates the wrong impression that the Window remains for anything other than looking at. It would be better for every control to be non-functioning by a single setting.
I did it by putting a name on the WPF window code behind and then setting .IsEnabled false upon the appropriate button click. All buttons, combo boxes, text boxes, and even OxyPlot became inert at that point and most parts were greyed out.
Consider creating a dedicated boolean dependency property in your code-behind or viewmodel and binding IsEnabled of every TextBox to the property.
I'm getting some inconsistent behavior when I disable certain Button controls in my VS2008 Winforms project.
When I set Enabled = false, the buttons are disabled, but the Text of some (though not all) of the buttons stays black.
I want all buttons to show grey text when disabled - this makes it much easier for the user to see that a button is disabled.
Seems more likely to happen if button is placed in a GroupBox, but I'm not sure this is always the case.
I'm guessing that some combination of properties of the Button, and/or those of the Form or GroupBox containing it are causing this, but I can't see any pattern that makes sense.
Edit: We have our own look and feel, and are setting the BackColor of the containing Form to a different color.
Can anyone explain why this might be happening?
Problem was because the Form's BackColor was set to a different color.
Some Googling revealed that many others have encountered this. The proposed solutions were very complex - subclassing your own button controls and overriding OnPaint, etc.
But it turns out there is a simple fix...
When you add the buttons to the form, the button's BackColor property will be set to the same value as the Form's BackColor, although it will not display that way either at design or run time.
If you set the button's BackColor property to System -> ControlLight, it will fix the problem - the disabled buttons now look disabled.
Note that there's a strange quirk when you reset the BackColor - the UseVisualStyleBackColor property will change from True to False. But this seems to have no effect, and can be changed back to True without affecting the appearance in any way.
I'm once again turning to you since I can't find an answer anywhere else. I have a TabControl, but I want to get rid of the ugly orange bar on top of the selected tabs. I would also like to make the tab text BOLD when selected and NORMAL when not.
Is there any easy way to achieve that goal ? I don't want to use the Appearance Buttons or Flat Buttons.
Thanks for your help !
This appearance is controlled by the Visual Styles theme selected in your operating system. In general, users do not appreciate any program that ignores their theme settings, especially when they paid money for a custom one. But you can get what you want, you'll have to set the DrawMode property to OwnerDrawFixed and implement a handler for the DrawItem event. There's a good example to get you started in the MSDN Library article for this event. Just change the font assignment in that sample code.
I am expecting the text on GroupBox caption and Button caption to be the same color if they have the same ForeColor (as well as other controls set similarly).
The ForeColor property of a GroupBox and several Buttons are each set to ControlText, but they render as blue (groupbox) and black (buttons). Assuming these match the current XP Theme. The question is how do I set the properties on these controls, or Winforms controls generally, such that their behavior is consistent and expected? Or is it correct already and I am misunderstanding?
That's not in general how theming works. It overrides the default properties of controls according to the user selected theme. A more stark example is ProgressBar.ForeColor, it's going to be the pulsing green bar on Vista, no matter what color you select in the designer.
Fwiw, there's a fair amount of pain you can get into when you try to override this. GroupBox.ForeColor is a very notable example. It is only going to have the theme color (it is faked btw) if you never assign ForeColor yourself. Once you do, you can never reset it back. Even if you assign ControlText again you'll get black, not the theme color. This is somewhat inevitable from the way 'ambient properties' are implemented in Windows Forms. Calling it a bug would not be unjustified. Not tinkering with it is the best way to avoid this trouble, your user isn't going to be complaining.
I have a program in which a user selects a row in a Datagrid and then clicks a "Start Recording" button. While "recording" is happening, they are not allowed to change the value selected in the datagrid, so I set IsEnabled to false. However, when the datagrid is set to be disabled, it deselects the selected row, which screws up any bindings I have to the datagrid's SelectedItem propery.
Is there any way to keep the datagrid row selected even though the control is disabled?
Edit: This does not happen in Windows Vista, but it does in Windows 7.
If you really want to 'record' actions but still keep visuals and interactions looking the same, why don't you just add a check to the event fired on selection to ensure that recording is not taking place and set e.Handled = true.
Alternatively you could set IsHitTestVisible = false and prevent them from taking actions in the control instead of disabling it outright.
Hope that helps.
Sorry I know this post is a little old, but I couldn't find another solution to this anywhere else.
It doesn't seem to be related to Vista\7, but to the Feb. release of the Toolkit.
You can set IsHitTestVisible = false as Jeff Wain suggests, but as Mike noted it doesn't appear different. Also, It doesn't disable Keyboard input.
My solution is to put the DataGrid in a Grid within the same row and column as a semitransparent gray rectangle (This will make them on top of one another). You have to put the rectangle in the Grid second to make sure it is on top of the DataGrid. When I want to 'disable' it I make the rectangle visible. This will make the list look dimmed and disable mouse inputs, but it still doesn't disable keyboard input.
To disable the keyboard I have to intercept 'PreviewKeyDown' and set e.Handdled = true. This will not allow anything else to be selected but will still do some interesting things when you tab to it (like tab no longer working). Perhaps setting it to not be a tab stop and not focusable will also fix this, but disabling selection is all I really care about.
IsHitTestVisible=false disables mouse inputs.
For disabling keyboard inputs set Focusable=false.
Both should be set via a style in ElementStyle and/or ElementEditingStyle for builtin datagrid columns inorder for the child control (textbox, checkbox, etc) to not accept input.
You'll most likely have to use a trigger in the style and bind it to some IsRecording value.
Also you could, in the same style, change the appearnce of the "disabled" controls by setting their Opacity=0.4, this gives somewhat of a disabled feel to them.