Creating standard VB controls dynamically


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Creating standard VB controls dynamically

  1. #1
    J Clark Guest

    Creating standard VB controls dynamically


    Hi guys. How do I go about creating a standard VB control, such as a textbox,
    in cod?. This is assuming I don't have an existing physical indexed textbox
    array already on the form (then I can just use the Load function). Do I need
    to use the CreateWindow Api ( an example would be appreciated if so ), or
    is there another way. Reason being, I have a custom control which basically
    provides a standard interface to 4 standard VB controls, textbox, listbox,
    optionbutton, and checkbox. I don't want to have these controls physically
    sitting on the control, since only one can be used at a time, so the other
    3 are just added overhead. Thanks for any help.

  2. #2
    Jonathan Wood Guest

    Re: Creating standard VB controls dynamically

    You can create a control array (at least one instance of each control type
    with the Index property set to something).

    Then just use the Load statement to load new control of that type.

    --
    Jonathan Wood
    SoftCircuits Programming
    http://www.softcircuits.com
    "J Clark" <jclark@wescodist.com> wrote in message
    news:3cd7d03d$1@10.1.10.29...
    >
    > Hi guys. How do I go about creating a standard VB control, such as a

    textbox,
    > in cod?. This is assuming I don't have an existing physical indexed

    textbox
    > array already on the form (then I can just use the Load function). Do I

    need
    > to use the CreateWindow Api ( an example would be appreciated if so ), or
    > is there another way. Reason being, I have a custom control which

    basically
    > provides a standard interface to 4 standard VB controls, textbox, listbox,
    > optionbutton, and checkbox. I don't want to have these controls physically
    > sitting on the control, since only one can be used at a time, so the other
    > 3 are just added overhead. Thanks for any help.




  3. #3
    Mark Alexander Bertenshaw Guest

    Re: Creating standard VB controls dynamically


    "Jonathan Wood" <jwood@softcircuits.com> wrote in message
    news:3cd7dadf@10.1.10.29...
    > You can create a control array (at least one instance of each control type
    > with the Index property set to something).
    > Then just use the Load statement to load new control of that type.


    Jonathan -

    What's the point? J Clark would still be in the same position as before,
    with 3 redundant controls on his UserControl!

    J Clark -

    If you have VB6 (as opposed to VB5), you can do:

    ----------------------------------------------------------------------------
    ---------------------------

    Private WithEvents m_ctl As VBControlExtender

    Private Sub UserControl_Initialize()
    Set m_ctl = Controls.Add("VB.TextBox", "txt")
    End Sub

    You receive all the events via m_ctl:

    Private Sub m_ctl_ObjectEvent(Info As EventInfo)
    Select Case Info.Name
    Case "Click"

    Case "Change"

    Case ...
    ' etc. etc.
    End Select
    End Sub

    ----------------------------------------------------------------------------
    ---------------------------

    The problem is that you can't set any design-time only properties - a major
    flaw IMO. Which means that you can't create Simple or DropDown combo boxes!

    A way around this is to use the Windowless controls which come with VB6.
    These allow you to change all read-only properties - but due to their
    Windowless nature, you can't use any API code with them.

    --
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Chordiant Software, Inc.
    Brentford
    UK



  4. #4
    Dmitry Guest

    Re: Creating standard VB controls dynamically


    hey !

    Dim WithEvents EntryLine As VBControlExtender
    Set EntryLine = Controls.Add("e▀Order.ItemControl", "EntryLine" &
    LocalRs.Fields("ID").Value, LinesFrame)


    =)

    "J Clark" <jclark@wescodist.com> wrote:
    >
    >Hi guys. How do I go about creating a standard VB control, such as a textbox,
    >in cod?. This is assuming I don't have an existing physical indexed textbox
    >array already on the form (then I can just use the Load function). Do I

    need
    >to use the CreateWindow Api ( an example would be appreciated if so ), or
    >is there another way. Reason being, I have a custom control which basically
    >provides a standard interface to 4 standard VB controls, textbox, listbox,
    >optionbutton, and checkbox. I don't want to have these controls physically
    >sitting on the control, since only one can be used at a time, so the other
    >3 are just added overhead. Thanks for any help.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center