PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
TableStyles missing from UserControl
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
TableStyles missing from UserControl
![]() |
TableStyles missing from UserControl |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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. > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#5 |
|
Guest
Posts: n/a
|
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. > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
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. |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

