Datagrid - where to initialize?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I derived a custom grid class from Forms.DataGrid to serve as a logging table. Currently I'm adding the columns in the grid's constructor. What I would like to have is a class that does this automatically when the grid is initialized. Then the columns would be added between to BeginInit and EndInit methods of the grid's ISupportInitialize interface. But I don't know what event to bind to or what to override.

Can someone help me out? Thanks,
 
Hi myself & others

----- TT (Tom Tempelaere) wrote: ----
I get the feeling that "Forms.Datagrid" is one of the most complex classes in .NET otherwise I would probably have >had an answer already. Anyway, ..

No kidding.
I searched again and I haven't found a good event to bind to similar to the "Load" event for a form, and I haven't >found a method I can override to do initialization stuff (setup the right columns etc). Can anyone give a clue as to what I >should do? Or perhaps a link to a site that explains how ..
Blablabla.

Another issue is that now, since I derived from Datagrid, I cannot see the grid in designer mode :'(. I remove any auto->generated code for a Datagrid I added to the form and place the initialization somewhere else (the code-generator >removes code in InitializeComponent methods). But now the grid is no longer drawn on the form ... pitty. So how can I >keep the grid drawn on the form??? Please help me I'm stuck on this

Well no longer I am. I kept the initialization stuff in the constructor of my DataGrid derived class and added the control to the toolbox (by referring the assembly that defines it). Damn, that was EZ! :

Tom T.
 
Hi, can you elaborate a little more on how you referenced the assembly to show the control in design mode? I am curious about this as well

(sry I do not know froms.datagrid enough

Thanks!
 
Back
Top