CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    78

    How can you determine the control type?

    Hi,

    I'm passing a control in a function and I want to determine the control type, such as combobox, textbox, etc.

    I set a variable as a control. I see a name property but that is the actual name give to the control and not the control type.

    How can you determine the control type?

    Many thanks,

    RF


  2. #2
    Join Date
    Aug 2000
    Location
    Ottawa, Canada
    Posts
    469

    Re: How can you determine the control type?

    When you call your function you probably know which control you're sending.
    So, creat your own enum and pass type of control as an additional parameter in function.
    Or, save the type of the control in its 'Tag' property and then read it in the function.


  3. #3
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: How can you determine the control type?


    private Sub Command1_Click()
    SomeSub Command1
    End Sub


    private Sub SomeSub(c as Control)
    If TypeOf c is CommandButton then
    MsgBox "It's a command button"
    End If
    If TypeOf c is ListBox then
    MsgBox "It's a listbox"
    End If
    'etc. etc. etc....
    End Sub





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