Results 1 to 5 of 5

Thread: [2008] User Control Button To Open New Form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    24

    [2008] User Control Button To Open New Form

    I am trying to create a User Control Button that will allow a button to be dropped on the form, then set the FormToOpen property with the form in the project that you want to Show. Here is what I have so far, but it doesn't seem to work this easy:

    Code:
    Public Class OpenWindowButton
        Inherits Button
    
        Private m_FormToOpen As Form
        Public Property FormToOpen() As Form
            Get
                Return m_FormToOpen
            End Get
            Set(ByVal value As form
                m_FormToOpen = value
            End Set
        End Property
    
    
        Private Sub m_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Click
            Dim NewForm As typeof(m_FormToOpen)
            NewForm.Show()
        End Sub
    
    End Class

  2. #2
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: [2008] User Control Button To Open New Form

    try

    m_FormToOpen.Show

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    24

    Re: [2008] User Control Button To Open New Form

    Quote Originally Posted by Besoup
    m_FormToOpen.Show
    That gets rid of my errors, but now my problem is setting which form to open in the property window. Although I have 2 forms in my project, I only get the form on which the button resides as the selection in the drop down box.

  4. #4
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: [2008] User Control Button To Open New Form

    can you post the code that is setting the form to the button?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Aug 2008
    Posts
    24

    Re: [2008] User Control Button To Open New Form

    Quote Originally Posted by Besoup
    can you post the code that is setting the form to the button?
    There is no more code than what is above. I created a new project, added a new class, then added the code above to the new class. I then build the project.

    I can then drag and drop the OpenWindowButton on the form (Class with code above), then go to the properties window for the button and set the FormToOpen property. In that property list, I need it t show all forms in the project, but it only shows 1.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width