Click here to Skip to main content
15,886,714 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been developing some custom controls ,but one control I cannot implement is the DataGridView control. Does anyone have articles on it? Also this is for the windows forms in Visual Studio .Net framework 4.0 which is the 2010 version. If you find a version dealing with 2012 the 4.5 framework that will do as well. :)
Posted
Updated 6-Jan-15 16:20pm
v2
Comments
Dave Kreskowiak 6-Jan-15 23:23pm    
Tutorials to do what exactly? Develop a DGV control from scratch or what?

By the way, the DGV is the biggest and most complex control in the toolbox, encompassing about 80+ classes.
Ray Raymos 7-Jan-15 12:00pm    
Yes it is very complex with all the customization you can do with the control is great. However I just want the DataGridView control designer code. So that I may inherit it in a new VB class file. Then I will add the imports for what is needed for the inherited and designer code portions. All I ask is the original DGV designer code. So from there I can just modify ,but I am having trouble finding the designer code for DGV.
Dave Kreskowiak 7-Jan-15 12:29pm    
You don't want the designer generated code. That's not going to do you any good as it just instantiates classes and sets their properties at runtime. That's not the stuff you use to create your own customized version of controls.

If you're looking to create your own custom columns, read these[^].
syed shanu 7-Jan-15 3:43am    
What type of Custom datagridview you want to create.There are many articles related to DGV but you need to mention what type of Custom DGV you want to create.
Ray Raymos 7-Jan-15 11:57am    
Well I would like any basic type of inheriting of the DataGridView. Fore example the Button control to make a custom button you must make a new VB class file. Then you must copy the code from the designer in the class with inheriting the button. Also you must import System.Drawing and System.Windows.Forms if these two are wrong I apologize ,because I am trying to remember exactly how to recreate it via message. Anyways I would like the datagridview designer code in Vb.net ,but however it is hard for me to find any resources on it. If you have the designer code of the DGV control. Sharing it would be nice. Sorry for the lengthy reply.

1 solution

One direction you may want to use is to initialize all or most of the DGV(s) used in your application by passing the DGV reference var to a shared sub. This will give each DGV a consistent look and state.

VB
Public Shared Sub InitGrid(ByRef dg As DataGridView)
     dg.Columns.Clear()
     Dim altcolor As Color = Color.FromArgb(215, 215, 255)
     Dim cellFont As Font = New Font("Arial", 8)
     Dim headerFont As Font = New Font("Arial", 8)
     Dim headerCellFont As New Font("Arial", 8, FontStyle.Underline)
     dg.AutoGenerateColumns = False
     dg.AllowUserToAddRows = False
     dg.AllowUserToDeleteRows = False
     dg.ReadOnly = True
     dg.AlternatingRowsDefaultCellStyle.BackColor = altcolor
     dg.ColumnHeadersDefaultCellStyle.Font = headerFont
     dg.RowsDefaultCellStyle.Font = cellFont
     dg.RowHeadersWidth = 17
     dg.EnableHeadersVisualStyles = False
     dg.RowTemplate.Height = 22
     dg.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing
     dg.ColumnHeadersHeight = 22
     dg.ColumnHeadersDefaultCellStyle.BackColor = Color.LightYellow
 End Sub

regs.

ron O.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900