replicate the customisation code for Datagrid?

sullyman

Active member
Joined
Nov 11, 2009
Messages
37
Programming Experience
Beginner
Hi folks,

I am building a winform project. It has 3 tabbed pages with 1 datagrid on each tab.

I have customised the first datagrid to my liking and now wish to replicate this customistaion to the other 2 datagrids.

What is the easiest/best to replicate the customisation code for Datagrid 2 and Datagrid 3. Is copying the code the only way and modifying it to point at Datagrid 2 & 3?

Any help appreciated.
 
Thanks

Must read up on procedures

Basically i would like to style a datagrid (Perhaps a usercontrol?)

Then i would like to call the styled datagrid for datagrids 1, 2 & 3

I'm a bit lost though on how to reference the styled datagrid to datagrid 1, 2 & 3. Is this even possible?

My thinking is that this will reduce code bloat etc. and also result in quicker design
 
sub datagrid_Properties(byref datagridtemp as datagridview)
'put your code using datagridtemp
'such as

datagridtemp.Visible=false

end sub

so anything you change for datagridtemp will change for the variable you put into the procedure.

example

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

datagrid_Properties(datagrid1) 'changes datagrid1 Enable property to false
datagrid_Properties(datagrid2) 'changes datagrid2 Enable property to false
datagrid_Properties(datagrid3) 'changes datagrid3 Enable property to false

End Sub


The Same thing goes for any other Controls
 
Thanks for reply but i'm still lost... Can you point me to any link for an example perhaps?

I'm not too good on terminology so if you can tell me what to google for, that would be great also
 
Let's say i customised my datagrid so the colour is green and connected it to a datasource

Now for example, i wish to place another datagrid in my forms so i drag another datagrid on the form and customise this datagrid so it is green and connect it to another datasource.

Is there a way to save a base green datagrid (usercontrol perhaps?) so i can drag this onto my forms and then hook up to individual datasets.

I'm starting a project where there could be 50 datagrids with 50 individual datasets so i'm looking for a way to code quicker and also if i make a change to the datagrid that it will update on all 50 datagrids
 
I haven't used an usercontrol yet but the logic behind that is have have a customized control that u can use over an over. So Yea you can use that.

50 datagrids sounds like a lot (memory usage). I'm fairly new VB.NET but I've taken a few classes of C++ , so a good thing to do is keep your memory usage to a minimal when creating programs.
 
I'm fairly new myself so looking for information on best route forward. I don't plan to load all data at once. I have a treelist working that calls data in SQL Server on an individual datagrid when a user clicks on a node etc. Not sure does the usercontrol or not loading all data at once keeps memory usage low though
 
Back
Top