User Control in Vb.net
-
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
-
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
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
-
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
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.
-
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.
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
-
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
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.
-
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.
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