[Solved] - How to change the border datagrid when clicking the button?

Hi,
I was trying to change borderstyle by code but failed. 

 If f_DataGridView.Style.BorderStyle = BorderStyle.None Then f_DataGridView.Style.BorderStyle = BorderStyle.FixedSingle

How can i do this?


4 Replies

SS Susmitha Sundar Syncfusion Team May 13, 2020 05:39 PM UTC

Hi khanh dang, 
 
Thank you for using Syncfusion controls. 
 
We were able replicate your reported scenario. Currently, we are analyzing the same. We will validate and update you the details on or before May 15, 2020. We appreciate your patience until then. 
 
Regards, 
Susmitha S 



SS Susmitha Sundar Syncfusion Team May 16, 2020 09:35 AM UTC

Hi khanh dang, 
 
Thank you for your patience. 
 
Currently, we don’t have direct support to change the BorderStyle for SfDataGrid. But we have achieved this by workaround. We suggest to use this work around. Please refer the below code, 
 
private void button1_Click(object sender, EventArgs e) 
 { 
     this.sfDataGrid1.Style.BorderStyle = BorderStyle.FixedSingle; 
     this.sfDataGrid1.Style.BorderColor = Color.Red; 
     MethodInfo method = this.sfDataGrid1.GetType().GetMethod("UpdateStyles", BindingFlags.Instance | BindingFlags.NonPublic); 
     method.Invoke(this.sfDataGrid1, null); 
 } 
 
 
Please check the sample and let us know if you need further assistance on this. 
 
Regards, 
Susmitha S 



TG The GridLock May 16, 2020 11:24 AM UTC

Thanks Susmitha,
It's necessary for me in some cases


SS Susmitha Sundar Syncfusion Team May 18, 2020 07:34 AM UTC

Hi khanh dang, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Susmitha S 


Loader.
Up arrow icon