Results 1 to 4 of 4

Thread: userdefined control

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52

    userdefined control

    hi!

    has anybody experience in programming userdefined controls?

    i need a control which looks like that


    if the user clicks on the button inside the textbox an event should be raised.

    thanks for your help
    Robert

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    In your VB project click Add New Item (from the File menu) and select User Control.

    Add the controls you want (e.g. the text box and the button) to this new user control and write the code behind the button:

    VB Code:
    1. raiseevent blah

    You'll have to declare the event in the user control as follows:
    VB Code:
    1. Public Event blah()

    Close and save the user control and then build your solution.

    Look in the toolbox and you should find your new user control. Drop it on a form and you should be able to find the following event in the form.

    VB Code:
    1. Private Sub UserControl11_blah() Handles UserControl11.blah
    2.  
    3. End Sub
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Austria
    Posts
    52
    ok... that work's but it doesn't look like what i expected



    Maybe there is a way to use a combobox instead of a textbox + button and the click-event which opens the dropdown-list could be used.

    I experimented with this idea but it doesn't work because the OnDrawItem is fired more than one time if i click on the dropdown-button.

    Code:
    Imports System.ComponentModel
    Imports System.Drawing
    
    Public Class MultiComboBox
        Inherits ComboBox
    
        Protected Overrides Sub OnDrawItem(ByVal ea As DrawItemEventArgs)
    
            ' do what i want to do
    
        end sub
    I'm sure that also the small arrow can be changed to (...) but i've no idea how to do this.

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Maybe you could try using a flat style textbox with a standard button and putting them both on top of a 3D style Panel control.

    I too have had problems making my user controls look as good as the supplied ones.

    I have come to the conclusion that it is best to redesign your UI to work with standard controls - that is what your users will be used to in any case.
    This world is not my home. I'm just passing through.

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