PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms TableStyles missing from UserControl

Reply

TableStyles missing from UserControl

 
Thread Tools Rate Thread
Old 14-12-2005, 04:02 PM   #1
=?Utf-8?B?RGljaw==?=
Guest
 
Posts: n/a
Default TableStyles missing from UserControl


I have a UserControl that contains a DataGrid control. The UserControl
exposes the TableStyles property of the constituent DataGrid to the outside
world

Public ReadOnly Property TableStyles() As
Windows.Forms.GridTableStylesCollection
Get
Return Me.Grid.TableStyles
End Get
End Property

When the UserControl is dropped onto a form the designer allows you to add
and modify the table styles through the table style editor just like it were
an ordinary DataGrid. and all of the code for the TableStyle,
CollumnHeaderStyles etc.. are added to the initialise component method of the
form as would be expected. However the line that should read

Me.NewDataGrid.TableStyles.AddRange(New
System.Windows.Forms.DataGridTableStyle() {Me.DataGridTableStyle1})

is not added to the code in initialise component. So, when you close the
table style editor the table style is not associated with the control as it
would be if it were an ordinary DataGrid. Adding the above line manually
after initialise component means that at runtime the table styles will apply,
but I cannot easily use the designer as I would like.

What am I missing please.
  Reply With Quote
Old 15-12-2005, 05:45 AM   #2
Jeffrey Tan[MSFT]
Guest
 
Posts: n/a
Default RE: TableStyles missing from UserControl

Hi Richard,

Thanks for your post.

Yes, I can reproduce out your issue.

Actually, we should apply DesignerSerializationVisibility.Content attribute
to this property, so that form designer will serialize the property for us.
Like this:
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public ReadOnly Property TableStyles() As
Windows.Forms.GridTableStylesCollection
Get
Return Me.DataGrid1.TableStyles
End Get
End Property

After applying this attribute, my sample works well.

Hope it helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

  Reply With Quote
Old 15-12-2005, 10:43 AM   #3
=?Utf-8?B?QmVuIFJlZXNl?=
Guest
 
Posts: n/a
Default RE: TableStyles missing from UserControl

Thank you Jeffrey. That seems to have done the trick.

Why is this different from simply adding a normal property to the control?
Public Property Foo() as String
Get

End get
Set(value as String)

End Set
End Property

The designer will store this property without doing anything special

Thanks

Ben

""Jeffrey Tan[MSFT]"" wrote:

> Hi Richard,
>
> Thanks for your post.
>
> Yes, I can reproduce out your issue.
>
> Actually, we should apply DesignerSerializationVisibility.Content attribute
> to this property, so that form designer will serialize the property for us.
> Like this:
> <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
> Public ReadOnly Property TableStyles() As
> Windows.Forms.GridTableStylesCollection
> Get
> Return Me.DataGrid1.TableStyles
> End Get
> End Property
>
> After applying this attribute, my sample works well.
>
> Hope it helps
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>

  Reply With Quote
Old 16-12-2005, 02:24 AM   #4
Jeffrey Tan[MSFT]
Guest
 
Posts: n/a
Default RE: TableStyles missing from UserControl

Hi,

I am not sure if you are Richard. Normally,
DesignerSerializationVisibility.Content indicates that each public,
non-hidden sub-property of the object will be serialized. While if we do
not specify this attribute explicitly, it will default be
DesignerSerializationVisibility.Visible, which means code generator only
produces code for the object.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

  Reply With Quote
Old 16-12-2005, 02:38 PM   #5
=?Utf-8?B?QmVuIFJlZXNl?=
Guest
 
Posts: n/a
Default RE: TableStyles missing from UserControl

Thank you

I understand

Ben (Richard)

""Jeffrey Tan[MSFT]"" wrote:

> Hi,
>
> I am not sure if you are Richard. Normally,
> DesignerSerializationVisibility.Content indicates that each public,
> non-hidden sub-property of the object will be serialized. While if we do
> not specify this attribute explicitly, it will default be
> DesignerSerializationVisibility.Visible, which means code generator only
> produces code for the object.
>
> Thanks
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>

  Reply With Quote
Old 19-12-2005, 02:20 AM   #6
Jeffrey Tan[MSFT]
Guest
 
Posts: n/a
Default RE: TableStyles missing from UserControl

You are welcome

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off