Windows Form Designer question, please help....  
Author Message
pomp





PostPosted: Visual Basic General, Windows Form Designer question, please help.... Top

Hello. Um, I'm very frustrated right now. I don't get why this is happening. When I add a control to the form, And I type it's name in the code to set a property or whatever, it has those squiggly lines under it because he doesn't know it. Isn't that #region Windows form designer supposed to show up once you add a control in the form ! It's not, ugh. It's there for my other projects. I hope someone can help, asap. Thanks


Visual Basic14  
 
 
Ayhan Yerli





PostPosted: Visual Basic General, Windows Form Designer question, please help.... Top

Normally, when you add an object to a windows form, Visual Studio adds the code automatically. It is really odd if the object is not known by the editor. Please view the code of the Form where you created the object. On code page, you see 2 drop down menus (comcocoxes). Left menu is the objects and the right menu is the methods. if you can see your object on the left menu, it means that you can use the object.

If it is the case then make sure that you are trying to use the object within the same form and in a SUB.

You might be trying to access to the object from out of its scope, maybe from another form.
By default, this newly created object's "Modifier" property is set to "Friend " , which means that, the object can be accesed only with in the form or instances of the form.  

if you want to access this object from another form then, there are several things that you can do

The easiest way:

Open your form in design view
Select your object
Open the Properties window
You will see "Modifiers" property.  From the drop down menu, select the "Public". Now you can access your object from the other forms..

Or create a public Property which can be accesed via other forms within the same project

Public Property mTextBox() As TextBox
  Get
    Return Me.TextBox1
  End Get
  Set(ByVal value As TextBox)
    If Not value.Equals(Me.TextBox1) Then
      Me.TextBox1 = value
    End If
  End Set
End Property

I hope it helps

regards,

Ayhan