Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. User Control in Vb.net

User Control in Vb.net

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasevisual-studiohelp
6 Posts 5 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wael Hawari
    wrote on last edited by
    #1

    Hi experts, i am developing a window application, using VS 2005, i created a user control that contain a Combobox and error provider for my combo. Everything worked just fine until i needed to use the event SelectedindexChange, in fact, in my form i have my user control(containing Combo box) and a checked list box. For each value in my Combo box i have to load different values into my checked list box Therefore, i need to use the event selectedindexchange in my form can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed? If there is another way hope to share it. the code of my user control (if there is any remarks or anything that i could be written much better or missing i will be thankful to tell me) Public Class All_In_One_ComboBox Private Err_Msg As String Private Index As Integer Private Err As Boolean = False Private Back_Color As Color = Color.White Private Fore_Color As Color = Color.Black Private _Font As New Font("Microsoft Sans Serif", 12, FontStyle.Regular, GraphicsUnit.Point) Public Property My_Back_Color() As Color Get My_Back_Color = Back_Color End Get Set(ByVal value As Color) Me.My_ComboBox.BackColor = value End Set End Property Public Property My_Fore_Color() As Color Get My_Fore_Color = Fore_Color End Get Set(ByVal value As Color) Me.My_ComboBox.ForeColor = value End Set End Property Public Property My_Text() As String Get My_Text = Trim(Me.My_ComboBox.Text) End Get Set(ByVal Value As String) Me.My_ComboBox.Text = Value End Set End Property Public Property My_Index() As Integer Get My_Index = Index End Get Set(ByVal Value As Integer) Index = Value End Set End Property Public Property My_Err_Rslt() As Boolean Get My_Err_Rslt = Err End Get Set(ByVal value As Boolean) Err = value End Set End Property Public Property My_Err_Msg() As String Get My_Err_Msg = Err_Msg End Get Set(ByVal value As String) Err_Msg = value End Set End Property Public Property My_Font() As Font Get My_Font = _Font End Get Se

    P D G 3 Replies Last reply
    0
    • W Wael Hawari

      Hi experts, i am developing a window application, using VS 2005, i created a user control that contain a Combobox and error provider for my combo. Everything worked just fine until i needed to use the event SelectedindexChange, in fact, in my form i have my user control(containing Combo box) and a checked list box. For each value in my Combo box i have to load different values into my checked list box Therefore, i need to use the event selectedindexchange in my form can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed? If there is another way hope to share it. the code of my user control (if there is any remarks or anything that i could be written much better or missing i will be thankful to tell me) Public Class All_In_One_ComboBox Private Err_Msg As String Private Index As Integer Private Err As Boolean = False Private Back_Color As Color = Color.White Private Fore_Color As Color = Color.Black Private _Font As New Font("Microsoft Sans Serif", 12, FontStyle.Regular, GraphicsUnit.Point) Public Property My_Back_Color() As Color Get My_Back_Color = Back_Color End Get Set(ByVal value As Color) Me.My_ComboBox.BackColor = value End Set End Property Public Property My_Fore_Color() As Color Get My_Fore_Color = Fore_Color End Get Set(ByVal value As Color) Me.My_ComboBox.ForeColor = value End Set End Property Public Property My_Text() As String Get My_Text = Trim(Me.My_ComboBox.Text) End Get Set(ByVal Value As String) Me.My_ComboBox.Text = Value End Set End Property Public Property My_Index() As Integer Get My_Index = Index End Get Set(ByVal Value As Integer) Index = Value End Set End Property Public Property My_Err_Rslt() As Boolean Get My_Err_Rslt = Err End Get Set(ByVal value As Boolean) Err = value End Set End Property Public Property My_Err_Msg() As String Get My_Err_Msg = Err_Msg End Get Set(ByVal value As String) Err_Msg = value End Set End Property Public Property My_Font() As Font Get My_Font = _Font End Get Se

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Thanks for the excessively long post :|

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      1 Reply Last reply
      0
      • W Wael Hawari

        Hi experts, i am developing a window application, using VS 2005, i created a user control that contain a Combobox and error provider for my combo. Everything worked just fine until i needed to use the event SelectedindexChange, in fact, in my form i have my user control(containing Combo box) and a checked list box. For each value in my Combo box i have to load different values into my checked list box Therefore, i need to use the event selectedindexchange in my form can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed? If there is another way hope to share it. the code of my user control (if there is any remarks or anything that i could be written much better or missing i will be thankful to tell me) Public Class All_In_One_ComboBox Private Err_Msg As String Private Index As Integer Private Err As Boolean = False Private Back_Color As Color = Color.White Private Fore_Color As Color = Color.Black Private _Font As New Font("Microsoft Sans Serif", 12, FontStyle.Regular, GraphicsUnit.Point) Public Property My_Back_Color() As Color Get My_Back_Color = Back_Color End Get Set(ByVal value As Color) Me.My_ComboBox.BackColor = value End Set End Property Public Property My_Fore_Color() As Color Get My_Fore_Color = Fore_Color End Get Set(ByVal value As Color) Me.My_ComboBox.ForeColor = value End Set End Property Public Property My_Text() As String Get My_Text = Trim(Me.My_ComboBox.Text) End Get Set(ByVal Value As String) Me.My_ComboBox.Text = Value End Set End Property Public Property My_Index() As Integer Get My_Index = Index End Get Set(ByVal Value As Integer) Index = Value End Set End Property Public Property My_Err_Rslt() As Boolean Get My_Err_Rslt = Err End Get Set(ByVal value As Boolean) Err = value End Set End Property Public Property My_Err_Msg() As String Get My_Err_Msg = Err_Msg End Get Set(ByVal value As String) Err_Msg = value End Set End Property Public Property My_Font() As Font Get My_Font = _Font End Get Se

        D Offline
        D Offline
        Dirk Higbee
        wrote on last edited by
        #3

        Waoula wrote:

        can anyone teach me

        sure go to Google and type 'VB.net index changed user control function' in the search box

        Don't take any wooden nickels.

        M 1 Reply Last reply
        0
        • D Dirk Higbee

          Waoula wrote:

          can anyone teach me

          sure go to Google and type 'VB.net index changed user control function' in the search box

          Don't take any wooden nickels.

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Out of curiosity I did, first hit, this question ;P When I have used a user control I put all the management for the control in the code behind the control (it worked Ok for the rare occasions I have needed a UC)

          Never underestimate the power of human stupidity RAH

          1 Reply Last reply
          0
          • W Wael Hawari

            Hi experts, i am developing a window application, using VS 2005, i created a user control that contain a Combobox and error provider for my combo. Everything worked just fine until i needed to use the event SelectedindexChange, in fact, in my form i have my user control(containing Combo box) and a checked list box. For each value in my Combo box i have to load different values into my checked list box Therefore, i need to use the event selectedindexchange in my form can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed? If there is another way hope to share it. the code of my user control (if there is any remarks or anything that i could be written much better or missing i will be thankful to tell me) Public Class All_In_One_ComboBox Private Err_Msg As String Private Index As Integer Private Err As Boolean = False Private Back_Color As Color = Color.White Private Fore_Color As Color = Color.Black Private _Font As New Font("Microsoft Sans Serif", 12, FontStyle.Regular, GraphicsUnit.Point) Public Property My_Back_Color() As Color Get My_Back_Color = Back_Color End Get Set(ByVal value As Color) Me.My_ComboBox.BackColor = value End Set End Property Public Property My_Fore_Color() As Color Get My_Fore_Color = Fore_Color End Get Set(ByVal value As Color) Me.My_ComboBox.ForeColor = value End Set End Property Public Property My_Text() As String Get My_Text = Trim(Me.My_ComboBox.Text) End Get Set(ByVal Value As String) Me.My_ComboBox.Text = Value End Set End Property Public Property My_Index() As Integer Get My_Index = Index End Get Set(ByVal Value As Integer) Index = Value End Set End Property Public Property My_Err_Rslt() As Boolean Get My_Err_Rslt = Err End Get Set(ByVal value As Boolean) Err = value End Set End Property Public Property My_Err_Msg() As String Get My_Err_Msg = Err_Msg End Get Set(ByVal value As String) Err_Msg = value End Set End Property Public Property My_Font() As Font Get My_Font = _Font End Get Se

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            Waoula wrote:

            can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed?

            You could, but you shouldn't, as the code gets harder to follow and maintain. Handle the even in the form where the control is that causes the event, and from that event handler just call a method (or set a property) in your user conrol.

            Despite everything, the person most likely to be fooling you next is yourself.

            W 1 Reply Last reply
            0
            • G Guffa

              Waoula wrote:

              can anyone teach me please how to create an event in my form to fire a function in my usercontrol when the index is changed?

              You could, but you shouldn't, as the code gets harder to follow and maintain. Handle the even in the form where the control is that causes the event, and from that event handler just call a method (or set a property) in your user conrol.

              Despite everything, the person most likely to be fooling you next is yourself.

              W Offline
              W Offline
              Wael Hawari
              wrote on last edited by
              #6

              Thanks Guys. in fact i found it, all i have to do is: declaring a new event to my user control Public Event Selected_Index_Changed() and this Public Sub My_ComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.SelectedIndexChanged Index = Me.My_ComboBox.SelectedIndex RaiseEvent Selected_Index_Changed() End Sub so when the combo box change index the user control raiseevent Selected_Index_Changed this way i can use it in the original form sorry if my post was to long just wanted to share my ideas and make the code much more better thanks again.

              waelhawari

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups