I have five UltraCheckEditors which have their Style property set to EditCheckStyle.Button.
I have an UltraButton on the same form.
The UltraCheckEditors have a blue border around them.
There are other differences in the appearance between the UltraButton and the UltraCheckEditors.
My goal is that the UltraButton and UltraCheckEditors have the same style and appearance, when the UltraCheckEditors are not in the toggled mode.
How can I accomplish this?
So far I have tried code lines like the following without any success:
ultraCheckEditor.UseOsThemes = DefaultableBoolean.False;
ultraCheckEditor.ButtonStyle = ultraButton.ButtonStyleResolved;
ultraCheckEditor.Appearance = ultraButton.Appearance;
Hello Burak,
Thank you for posting. Your code is looking correct to me except you disable the theme for ultraCheckEditor only.
I tried disabling the theme for both the controls and set the same ButtonStyle to them, now both the buttons looking same to me.The ButtonStyleResolved has no meaning at all if the button is using themes.
So if you try this code the UltraButton and UltraCheckEditors have the same style and appearance.
private void Form1_Load(object sender, EventArgs e) { ultraCheckEditor1.Style = EditCheckStyle.Button; ultraCheckEditor1.UseOsThemes = DefaultableBoolean.False ; // ultraCheckEditor1.ButtonStyle = ultraButton1.ButtonStyleResolved; //ultraCheckEditor1.Appearance = ultraButton1.Appearance; ultraCheckEditor1.ButtonStyle = UIElementButtonStyle.Button; ultraButton1.UseOsThemes = DefaultableBoolean.False ; ultraButton1.ButtonStyle = UIElementButtonStyle.Button; }
Please let me know if you need further assistance.
Sincerely,Divya JainAssociate Software Developer
Thank you for your answer, Divya.
We have an application with hundreds of UltraButtons and we'd rather keep their style and appearance as the current OsTheme, because our application is being used across multiple OS versions. That way our application blends smoothly with the rest of the programs on whatever OS version we install it.
Now, I'm adding five UltraCheckEditors as buttons. I want the UltraCheckEditor buttons to have the same style and appearance as the other UltraButtons.
So in essence, I need the UltraButtons to use the OSTheme, and the UltraCheckEditors as buttons to have the same appearance as the UltraButtons.
Is there a way to do that?
The way themed drawing works is that when the UltraButton control draws itself, it calls off to the Winforms API and tells it to draw a themed button. Themed drawing is all or nothing. The OS draws the entire button.
And similarly, when the CheckBox draws itself, it tells the Windows API to draw a State Button. Since the O/S draws buttons and state buttons differently - they look different.
One approach you could take here would be to use a DrawFilter and handle the BeforeDrawTheme phase of the UltraCheckEditor and then handle the drawing yourself and draw it like a Button using the same themed drawing that the UltraButton uses.
The problem with this approach is that there is no such thing as a "Checked" button. In other words, the themed drawing for a State Button in Windows has options for the checked state - it can draw checked, unchecked, or indeterminate. There are no such states for a regular button.
So, you would have to figure out some way to draw a "checked" state. I thought maybe it would be a good idea to use the MouseDown state of the Button as the 'checked' state of the CheckBox. it turns out that the MouseDown state doesn't look any different. So then I tried using the MouseOver state and that seems to work pretty well.
The down side of this approach is that when you mouse over a checked UltraCheckEditor, it doesn't change, because it's already displaying as though the mouse was over it.
And also that you have to apply the DrawFilter to every UltraCheckEditor in your application - there's no way to do it globally.
I have attached a sample here with a DrawFilter you can use if you decide you want to use this approach.
WindowsFormsApplication22.zip
Thank you for the answer and the sample project. This solved my problem.
Thank you for the update, I am glad that you solved the issue.