CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: TextBox

  1. #1
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    TextBox

    Hello,

    Is there a way to do the following. Instead of draging a textbox control to a form during design time, can I do that from within the code.

    I tried

    dim x as textbox

    load method

    set x = new textbox.

    Did not work... ANy Ideas??? Please let me know




    Thanks
    Hisham
    Thank You, Hisham

  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: TextBox

    Hee is a sample that will create a Command Button at run time. Easly changed to create a textbox

    option Explicit

    ' Declare object variable as CommandButton.
    private withevents cmdObject as CommandButton

    private Sub Form_Load()
    set cmdObject = frmCreate.Controls.Add("VB.CommandButton", "cmdOne")
    cmdObject.Visible = true
    cmdObject.Caption = "Dynamic Command Button"
    cmdObject.Move 1000, 1000, 1000, 1000
    End Sub

    private Sub cmdObject_Click()
    print "This is a dynamically added control"
    End Sub

    private Sub Form_Unload(Cancel as Integer)
    ' get rid of created control
    me.Controls.Remove cmdObject

    End Sub




    John G

  3. #3
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Re: TextBox

    Thanx a lot John. Worked fine.

    Thanks
    Hisham
    Thank You, Hisham

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

Featured