Click here to Skip to main content
15,888,521 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questiondownload Login form Pin
pranavrana26-Jul-08 21:21
pranavrana26-Jul-08 21:21 
AnswerRe: download Login form Pin
Rupesh Kumar Swami26-Jul-08 21:28
Rupesh Kumar Swami26-Jul-08 21:28 
Questionsearch button control issue Pin
vidhish26-Jul-08 20:15
vidhish26-Jul-08 20:15 
AnswerRe: search button control issue Pin
Luc Pattyn27-Jul-08 1:20
sitebuilderLuc Pattyn27-Jul-08 1:20 
QuestionHow to paste information? Pin
wabby26-Jul-08 8:27
wabby26-Jul-08 8:27 
AnswerRe: How to paste information? Pin
Guffa26-Jul-08 14:42
Guffa26-Jul-08 14:42 
AnswerRe: How to paste information? Pin
Mycroft Holmes26-Jul-08 15:57
professionalMycroft Holmes26-Jul-08 15:57 
QuestionUser Control in Vb.net Pin
Wael Hawari25-Jul-08 23:56
Wael Hawari25-Jul-08 23:56 
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

Set(ByVal value As Font)
Me.My_ComboBox.Font = value
End Set
End Property

Private Sub My_ComboBox_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.BackColorChanged
Back_Color = Me.My_ComboBox.BackColor
End Sub

Private Sub My_ComboBox_FontChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.FontChanged
_Font = Me.My_ComboBox.Font
End Sub

Private Sub My_ComboBox_ForeColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.ForeColorChanged
Fore_Color = Me.My_ComboBox.ForeColor
End Sub

Private Sub All_In_One_ComboBox_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Me.My_ComboBox.Width = Me.Width - 20
Me.My_ComboBox.Height = Me.Height
End Sub

Private Sub My_ComboBox_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles My_ComboBox.KeyUp
Call Me.Auto_complete(e)
End Sub

Public Sub My_ComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles My_ComboBox.SelectedIndexChanged
Index = Me.My_ComboBox.SelectedIndex
End Sub

Private Sub My_ComboBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles My_ComboBox.Validating
If Me.My_ComboBox.Text = "" Then
Me.Err_Msg_Prv.SetError(Me.My_ComboBox, My_Err_Msg)
Err = True
Else
Me.Err_Msg_Prv.SetError(Me.My_ComboBox, "")
Err = False
End If
End Sub

Public Sub Load_Data_In_My_Combo(ByVal My_Data As DataTable, ByVal Column_Name As String)
Me.My_ComboBox.Items.Clear()
Dim i As Integer = 0
While i < My_Data.Rows.Count
Me.My_ComboBox.Items.Add(My_Data.Rows(i).Item(Column_Name))
i = i + 1
End While
End Sub

Public Sub Add_Item(ByVal My_Item As String)
Me.My_ComboBox.Items.Add(My_Item)
End Sub

Public Sub Clear_All_Items()
Me.My_ComboBox.Items.Clear()
End Sub

Private Sub Auto_complete(ByVal e As System.Windows.Forms.KeyEventArgs)
Dim My_String As String
Dim My_Found_String As String
Dim Match_Found As Boolean
If Not Me.My_ComboBox.Text = "" Then 'if the text is not blank then only proceed
If e.KeyCode = Keys.Back Then
Me.My_ComboBox.Text = Mid(Me.My_ComboBox.Text, 1, Len(Me.My_ComboBox.Text) - 1)
End If
If ((e.KeyCode = Keys.Left) Or _
(e.KeyCode = Keys.Right) Or _
(e.KeyCode = Keys.Up) Or _
(e.KeyCode = Keys.Down) Or _
(e.KeyCode = Keys.PageUp) Or _
(e.KeyCode = Keys.PageDown) Or _
(e.KeyCode = Keys.Home) Or _
(e.KeyCode = Keys.End)) Then
Return
End If
Do
My_String = Me.My_ComboBox.Text
Index = Me.My_ComboBox.FindString(My_String)
If (Index > -1) Then '** FOUND SECTION **
My_Found_String = Me.My_ComboBox.Items(Index).ToString()
' Select this item from the list.
Me.My_ComboBox.SelectedIndex = Index
Me.My_ComboBox.SelectionStart = My_String.Length
Me.My_ComboBox.SelectionLength = My_Found_String.Length
Match_Found = True

Else '** NOT FOUND SECTION **
If My_String.Length = 1 Or My_String.Length = 0 Then
Me.My_ComboBox.SelectedIndex = 0
Me.My_ComboBox.SelectionStart = 0
Me.My_ComboBox.SelectionLength = Len(Me.My_ComboBox.Text)
Match_Found = True
Else
Me.My_ComboBox.SelectionStart = My_String.Length - 1
Me.My_ComboBox.SelectionLength = My_String.Length - 1
Me.My_ComboBox.Text = Mid(Me.My_ComboBox.Text, 1, Len(Me.My_ComboBox.Text) - 1)
End If
End If
Loop Until Match_Found
End If
End Sub
Public Event My_Combo_Selected_IndexChange()


Public Sub My_Combo_Selected_Index_Change()
RaiseEvent My_Combo_Selected_IndexChange()

End Sub

Public Sub test() Handles Me.My_Combo_Selected_IndexChange
Index = Me.My_ComboBox.SelectedIndex
MsgBox(Index)
End Sub

End Class


the help that i needed is here:
Public Event My_Combo_Selected_IndexChange()


Public Sub My_Combo_Selected_Index_Change()
RaiseEvent My_Combo_Selected_IndexChange()
End Sub

Public Sub test() Handles Me.My_Combo_Selected_IndexChange
Index = Me.My_ComboBox.SelectedIndex
MsgBox(Index)
End Sub

waelhawari

RantRe: User Control in Vb.net Pin
Paul Conrad26-Jul-08 7:48
professionalPaul Conrad26-Jul-08 7:48 
AnswerRe: User Control in Vb.net Pin
Dirk Higbee26-Jul-08 15:23
Dirk Higbee26-Jul-08 15:23 
GeneralRe: User Control in Vb.net Pin
Mycroft Holmes26-Jul-08 16:01
professionalMycroft Holmes26-Jul-08 16:01 
AnswerRe: User Control in Vb.net Pin
Guffa27-Jul-08 5:18
Guffa27-Jul-08 5:18 
GeneralRe: User Control in Vb.net Pin
Wael Hawari27-Jul-08 8:47
Wael Hawari27-Jul-08 8:47 
QuestionDelegate in vb.net Pin
Ahamed Azeem25-Jul-08 22:58
Ahamed Azeem25-Jul-08 22:58 
AnswerRe: Delegate in vb.net Pin
jzonthemtn26-Jul-08 2:21
jzonthemtn26-Jul-08 2:21 
QuestionString Builder remove white spaces Pin
member2725-Jul-08 21:26
member2725-Jul-08 21:26 
AnswerRe: String Builder remove white spaces Pin
jzonthemtn26-Jul-08 2:26
jzonthemtn26-Jul-08 2:26 
Questionusername and passord problem Pin
monika_vasvani25-Jul-08 19:00
monika_vasvani25-Jul-08 19:00 
AnswerRe: username and passord problem Pin
jzonthemtn26-Jul-08 2:21
jzonthemtn26-Jul-08 2:21 
QuestionMaking TextBox visible Pin
Dalek Dave25-Jul-08 15:04
professionalDalek Dave25-Jul-08 15:04 
AnswerRe: Making TextBox visible Pin
Mycroft Holmes25-Jul-08 15:45
professionalMycroft Holmes25-Jul-08 15:45 
GeneralRe: Making TextBox visible Pin
Dalek Dave25-Jul-08 16:02
professionalDalek Dave25-Jul-08 16:02 
GeneralRe: Making TextBox visible Pin
Mycroft Holmes25-Jul-08 16:15
professionalMycroft Holmes25-Jul-08 16:15 
GeneralRe: Making TextBox visible Pin
Dalek Dave25-Jul-08 16:23
professionalDalek Dave25-Jul-08 16:23 
GeneralRe: Making TextBox visible Pin
Mycroft Holmes25-Jul-08 16:53
professionalMycroft Holmes25-Jul-08 16:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.