Reuse DataGridTableStyle

  • Thread starter Thread starter Rob Oldfield
  • Start date Start date
R

Rob Oldfield

Hi,

I have two datagrids (on the same Windows form) that are basically two
different filters of the same datatable. I've set up a table style for the
first one and I'm then trying to reuse that same style for the second
datagrid. That's giving the error "Cannot add a DataGridTableStyle already
parented to another DataGrid"

Any ideas how I can reuse it?
 
I'm assuming you are using the same instance of the DGTS. This cannot be
done, since the DGTS "is an object that represents the drawn grid" (from
help). You need to create a second instance.
 
I get what you mean... but am not sure exactly how to do it. I've tried
something like...

dim orig_ts as new datagridtablestyle
'set up orig_ts
dg_orig.tablestyles.add(orig_ts) 'air code... can't remember if i have the
syntax of that right

dim new_ts as new datagridtablestyle
new_ts=orig_ts
dg_new.tablestyles.add(new_ts)

I've just been thinking that maybe I should try doing the new_ts=orig_ts
before I set the style on the first datagrid. Is that it or am I missing
something?
 
I think you'd be better off having a method that intializes a table style
the way you want, and call it with each of your table style instances (or
something along those lines).
 
Nice idea. I'll give it a try tomorrow but it does seem that that should
work.

Thanks very much for the help.
 
Back
Top