Can not set border color an backgroud color

there is a sfButton on my form. FlatStyle is Flat. I can set background color in design time, please open attachment. but when i run the application, backgroud color is grey that is not my color. and also i can 

not set border color of sfButton. I read document that show me there is a border property. but i can not 

find this property when i design sfButton.



Attachment: sbButton_94f8b565.rar

3 Replies

MS Mahalakshmi Sugumar Syncfusion Team February 21, 2022 06:04 PM UTC

Hi Frank Liu,


Query 1: BackColor property now working properly in SfButton.


In SfButton control, the background color will be applied based on its button state by using BackColor, FocusedBackColor, HoverBackColor, PressedBackColor and DisabledBackColor properties.


We suspect that you have changed the background in designer using BackColor property. But when you run the application, the control might be in the focused state, so background color is applied based on FocusedBackColor property. We have prepared a sample based on your requirement in which we have customized the button background based on its state. Please find the code snippet, screenshot, and sample for the same from the below location.


this.sfButton1.Style.BackColor = System.Drawing.Color.GreenYellow;

this.sfButton1.Style.FocusedBackColor = System.Drawing.Color.LightPink;

this.sfButton1.Style.HoverBackColor = System.Drawing.Color.LightGoldenrodYellow;

this.sfButton1.Style.PressedBackColor = System.Drawing.Color.LightBlue;

this.sfButton1.Style.DisabledBackColor = System.Drawing.Color.LightYellow;



UG Documentation link: https://help.syncfusion.com/windowsforms/button/appearance#customizing-appearance-based-on-button-state

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SfButton-sample-1456521726.zip


Query 2: Border property was not shown in the smart tag of SfButton in the designer.


Currently, we did not have support to change the border color of SfButton in the designer using the smart tag. We suggest you to set the border color of SfButton manually in the code behind based on the button state by using the Border, HoverBorder, FocusedBorder, PressedBorder, and DisabledBorder properties. Please find the code snippet and UG Documentation link for the same from below:


this.sfButton1.Style.Border = new System.Drawing.Pen(System.Drawing.Color.Red);

this.sfButton1.Style.FocusedBorder = new System.Drawing.Pen(System.Drawing.Color.DarkBlue);

this.sfButton1.Style.HoverBorder = new System.Drawing.Pen(System.Drawing.Color.DarkOrange);

this.sfButton1.Style.PressedBorder = new System.Drawing.Pen(System.Drawing.Color.DarkViolet);

this.sfButton1.Style.DisabledBorder = new System.Drawing.Pen(System.Drawing.Color.DarkGreen);



UG Documentation link: https://help.syncfusion.com/windowsforms/button/appearance#border


If we misunderstood the query, please modify our sample, and revert to us with a reproducible issue or video. So, it will be helpful to prompt the solution on further.


Regards,
Mahalakshmi S



UM UMLer February 21, 2022 07:28 PM UTC

thanks, it is very helpful



MS Mahalakshmi Sugumar Syncfusion Team February 22, 2022 10:28 AM UTC

Hi UMLer,


We are glad to know that your issue has been fixed. Please let us know if you need any other assistance. We are happy to assist you.


Regards,

Mahalakshmi S


Loader.
Up arrow icon