c# - How do I change the datagridview defaults for a program -


In my current project I am trying to find a way to reset the default style for all the datagrid views in my project I am I was trying to install it in the designer but these changes remain only for the first generation and then overwritten.

The ultimate goal is that I will have a normal place where I can change the font size, alignment, color, etc ... and then those changes will be seen throughout the program. It will keep every Data Grid view in its project, without repeating the 20 times the values ​​of each separate datagrid view.

Update: The method of loading the DataGrade view was changed so that instead of setting all the data, instead of setting up a dataset, then we went to the dataset on Gridview and now we have done it in the Datagridware method (Designer With all the column settings) and only rows in the method. (Too many 'cleaner' solutions moved from line 1 line to 30 lines of code to load line)

You can do the sub code in the DataGridView class and set the properties that you want as the new default in the constructor. Then instead of using built in DataGridView you can use your new one.

  Public category MyGrid: DataGridView {Public MyGrid () {// Designer :) this.BackgroundColor = Color.AliceBlue; This.Forecolor = Color.Red; // Other properties ...}} If you are using this only in one project, then you can add this class to that project but if you have different DLL It can create (plus any other extended control). 

Back to your form, from the toolbox you can right click again and select the item ... if you browse the DLL in which you made the control (or Exe if it is in your exe project You can tick the control you made. It makes adding a very easy to the surface of the design:

Enter image details here < / P>

and control in the toolbox:

Enter image details here


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -