|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Is this Normal?with a partial class myform. The goal was to separate non-GUI properties and methods from the main form into its own file because it can be used by others. In the IDE, this 2nd file will display as a empty form. Q1) Is that normal? I don't think its normal. If you accidentally click on this empty form to create the load event, then you compiler errors and if you manually try to correct it by deleting the events, you get designer errors. Q2) Is what I did with a form partial class possible or should I do it another way? TIA -- On Jun 9, 3:16 pm, Mike <unkn***@unknown.tv> wrote:
Show quoteHide quote > I created a windows form class name myForm, and a 2nd class vb file Starting with VS2005, that ius the default way the IDE creates a new> with a partial class myform. The goal was to separate non-GUI > properties and methods from the main form into its own file because it > can be used by others. > > In the IDE, this 2nd file will display as a empty form. > > Q1) Is that normal? > > I don't think its normal. If you accidentally click on this empty form > to create the load event, then you compiler errors and if you > manually try to correct it by deleting the events, you get designer > errors. > > Q2) Is what I did with a form partial class possible or should I do it > another way? windows form. Create a new form the usual way. Select the form and click on the "Show All Files" button. You will see a plus sign appear next to the form. Click on it and you will now see a module named <your form name>.Designer.vb. It is the partial class that contains all of the designer code for the form. joecool1***@live.com wrote:
Show quoteHide quote > On Jun 9, 3:16 pm, Mike <unkn***@unknown.tv> wrote: That means sense now. But is odd because I did not "notice" the 2nd >> I created a windows form class name myForm, and a 2nd class vb file >> with a partial class myform. The goal was to separate non-GUI >> properties and methods from the main form into its own file because it >> can be used by others. >> >> In the IDE, this 2nd file will display as a empty form. >> >> Q1) Is that normal? >> >> I don't think its normal. If you accidentally click on this empty form >> to create the load event, then you compiler errors and if you >> manually try to correct it by deleting the events, you get designer >> errors. >> >> Q2) Is what I did with a form partial class possible or should I do it >> another way? > > Starting with VS2005, that ius the default way the IDE creates a new > windows form. > > Create a new form the usual way. Select the form and click on the > "Show All Files" button. You will see a plus sign appear next to the > form. Click on it and you will now see a module named <your form > name>.Designer.vb. It is the partial class that contains all of the > designer code for the form. one show up as a form. I was working on this for a few days because it was noticed double clicking on the 2nd file to view the code. when the empty form came up, it surprise me. I see the 1st form designer has an attribute: <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class WildcatLoginForm Maybe there is an attribute I can add to the 2nd one to disable the Designer for it? I am currently working on the organization (something I had to do at some point) but I need to get a better handle of namespaces, My, Me, MyBase, etc. Our frameworks allows for console and GUI login, so there is a base class that I want to be used for all cases. So it was probably a bad idea to use partial class for the base class with the same name as the form. The problem (and I figure i would address this later one I begin the final organization) was exposing functions. For example, in the form: Public Class WildcatLoginForm Public Settings As New LoginSettings Public NotInheritable Class LoginSettings Default Property Self(ByVal name As String) As Object Get Return My.Settings(name) End Get Set(ByVal value As Object) My.Settings(name) = value My.Settings.Save() End Set End Property End Class Private Sub btnLogin_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles cmdLogin.Click ... validate fields... If Not ConnectUser() Then Return End If Me.DialogResult = DialogResult.OK Me.Close() End Sub End Class What I had in the partial WildcatLoginForm was the ConnectUser() and other non-gui functions. The partial also had access to the field property bound My.Settings via LoginSettings class. So it worked nicely and when I did this, there was no empty form. So its odd. :-) But I am sure there is better organization and naming I can work out than using a partial here. -- Mike wrote:
> I created a windows form class name myForm, and a 2nd class vb file with SOLVED! I knew I wasn't crazy. I will chalk this one as a IDE bug :-)> a partial class myform. The goal was to separate non-GUI properties and > methods from the main form into its own file because it can be used by > others. > > In the IDE, this 2nd file will display as a empty form. > > Q1) Is that normal? > > I don't think its normal. If you accidentally click on this empty form > to create the load event, then you compiler errors and if you manually > try to correct it by deleting the events, you get designer errors. Like I said, when I first created the helper 2nd class vb file with the partial class of the form, the IDE did not view this as a form and show it as an empty form to display. The reason is that I had NON-PARTIAL class at the top of the file that I was first using to explore separating the non-gui functionality from the main form.vb file. That is when I added the partial class myform right below it and all was working fine. I must of removed this temporary class yesterday during a clean up process so now the first class at the top was the partial class MyForm. Then it began to look as a form to the IDE. In starting a reorganization just a few minutes ago, I added a Public Class at the top and PUFF - the IDE immediately removed the form status of this file!! Go figure! --
Variable String Limit
form top most when ran from sub main Copy Constructor needed in VB.NET 2.0? Shared Assembly FILE I/O Inheritance? Interface? Creating a list of a class OT: App respository Error adding a data provider to a datagridview control Autosize the last column in a ListView control using WndProc [2008] Collection of DipSwitches |
|||||||||||||||||||||||