JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
Okay,
There is some auto generated code by a designer, however, some of the functionality is not as I'd like it to be. I have found, quite painfully as it were, that editing the .Designer.vb file is possible but any accidental saving of the original design overwrites the code that I would add.
So here I am stuck with the situation of really liking the default generated code in a multitude of ways, but in a few, the generated code defeats how I would like my application to be designed.
So, given that, these classes are all declared as "Partial Class" which means that I can extend them, but so far I have not found a way to override the behaviors I don't want. Is this possible to do at all?
As example here is the Typed DataSet Design I would "like" to have:
My Idea
the Manager Property is currently in the Extend class version.
In effect I'm trying to control how the TableAdapter's Connections are created and assigned. Some may say this is unnecessary or probably redundant, but so far there is not method for me to control the connection strings of all the different connections, thus if any of the connections in all my TableAdapters are not linked to the connection with the "correct" connection string they generate an error. At the start of my form that logs into the database, i generate the connection and provide the log in information to the string via a SqlConnectionStringBuilder, then open the connection, so that I can work with the database openly. Because of this style of connecting I'm just trying to protect against the possibility that one of my TA's has the wrong connection. I've already setup a SetConnection() method in the class extension to set the connections for all my TA's but I like to make my code in a manner that protects all angles.
Besides, the ability to alter certain "generated" features would be rather helpful.
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
There is some auto generated code by a designer, however, some of the functionality is not as I'd like it to be. I have found, quite painfully as it were, that editing the .Designer.vb file is possible but any accidental saving of the original design overwrites the code that I would add.
So here I am stuck with the situation of really liking the default generated code in a multitude of ways, but in a few, the generated code defeats how I would like my application to be designed.
So, given that, these classes are all declared as "Partial Class" which means that I can extend them, but so far I have not found a way to override the behaviors I don't want. Is this possible to do at all?
As example here is the Typed DataSet Design I would "like" to have:
VB.NET:
[u].Designer.vb[/u]
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), _
Global.System.ComponentModel.DesignerCategoryAttribute("code"), _
Global.System.ComponentModel.ToolboxItem(True), _
Global.System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerDesigner, Microsoft.VSD" & _
"esigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), _
Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapterManager")> _
Partial Public Class TableAdapterManager
Inherits Global.System.ComponentModel.Component
Private _ta_tblBOL As ta_tblBOL
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerPropertyEditor, Microso" & _
"ft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" & _
"", "System.Drawing.Design.UITypeEditor")> _
Public Property ta_tblBOL() As ta_tblBOL
Get
Return Me._ta_tblBOL
End Get
Set(ByVal value As ta_tblBOL)
If ((Not (Me._ta_tblBOL) Is Nothing) _
AndAlso (Me.TableAdapterInstanceCount = 1)) Then
Me._ta_tblBOL = Value
Return
End If
If ((Not (Value) Is Nothing) _
AndAlso (Me.MatchTableAdapterConnection(Value.Connection) = False)) Then
Throw New Global.System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" & _
"tring.")
End If
Me._ta_tblBOL = Value
End Set
End Property
My Idea
VB.NET:
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), _
Global.System.ComponentModel.DesignerCategoryAttribute("code"), _
Global.System.ComponentModel.ToolboxItem(True), _
Global.System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerDesigner, Microsoft.VSD" & _
"esigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), _
Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapterManager")> _
Partial Public Class TableAdapterManager
Inherits Global.System.ComponentModel.Component
Private _ta_tblBOL As ta_tblBOL
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerPropertyEditor, Microso" & _
"ft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" & _
"", "System.Drawing.Design.UITypeEditor")> _
Public Property ta_tblBOL() As ta_tblBOL
Get
Return Me._ta_tblBOL
End Get
Set(ByVal value As ta_tblBOL)
If ((Not (Me._ta_tblBOL) Is Nothing) _
AndAlso (Me.TableAdapterInstanceCount = 1)) Then
Me._ta_tblBOL = Value
Me._ta_tblBOL.Manager = Me
Return
End If
If (Not (Value) Is Nothing)
value.Manager = Me
if (Me.MatchTableAdapterConnection(Value.Connection) = False)) Then
Throw New Global.System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" & _
"tring.")
End If
End If
Me._ta_tblBOL = Value
End Set
End Property
the Manager Property is currently in the Extend class version.
VB.NET:
Partial Class ta_tblBOL
Private _manager As TableAdapterManager
Public Property Manager() As TableAdapterManager
Get
Return _manager
End Get
Set(ByVal value As TableAdapterManager)
_manager = value
If (Not (value) Is Nothing) Then
If (value.Connection Is Nothing) Then
value.Connection = Me.Connection
Else
Me.Connection = value.Connection
End If
End If
End Set
End Property
End Class
In effect I'm trying to control how the TableAdapter's Connections are created and assigned. Some may say this is unnecessary or probably redundant, but so far there is not method for me to control the connection strings of all the different connections, thus if any of the connections in all my TableAdapters are not linked to the connection with the "correct" connection string they generate an error. At the start of my form that logs into the database, i generate the connection and provide the log in information to the string via a SqlConnectionStringBuilder, then open the connection, so that I can work with the database openly. Because of this style of connecting I'm just trying to protect against the possibility that one of my TA's has the wrong connection. I've already setup a SetConnection() method in the class extension to set the connections for all my TA's but I like to make my code in a manner that protects all angles.
Besides, the ability to alter certain "generated" features would be rather helpful.
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner