Results 1 to 8 of 8

Thread: Custom Control Question

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    4

    Custom Control Question

    I am fairly new to VB.Net. I have created a Custom Control with a couple of buttons on it. I am adding this control to a form programmatically at run time. I want one button on the control to be used to remove the control when it is clicked. I'm sure that there is a simple solution, but I am stumped.

    My routine to add the control to the form works fine

    Code:
     Private DynamicControl As New Object()
       
     Private Sub cmdCreateNew_Click(ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles cmdCreateNew.Click
    
          Dim NewControl As New ctrlCustomerInfo()
    
            NewControl.Left = 150
            NewControl.Top = 100
    
            Me.Controls.Add(NewControl)
            AddHandler NewControl.Click, AddressOf NewControl_Click
    
            DynamicControl = NewControl
       End Sub
    I also have a button already on the form that will take the control down. That works fine.

    Code:
    Private Sub cmdClear_Click(ByVal sender As System.Object, _
         ByVal e As System.EventArgs) Handles cmdClear.Click
    
            Dim MyControl As ctrlCustomerInfo
            MyControl = DynamicControl
           Me.Controls.Remove(MyControl)
    
       End Sub
    What I want to do is use a button that is on the new control in order to take the control down, but I can’t figure out how to do that.

    Any help would be greatly appreciated
    Last edited by SmartTrac; Apr 6th, 2004 at 08:57 PM.

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