T
tshad
In my VS 2003 Windows Forms page, when I initially fill my ComboBox
(SystemList), it goes to the SelectedIndexChanged event which calls the
Loademails() function. I then call it again in the Form1Load function.
How do I get it not to call it in the SelectedIndexChanged from the
Form1Load function? Normally, I want it to call it but not when I initally
fill the ComboBox.
*********************************************************
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Call LoadSystems()
Call Loademails(0)
End Sub
Private Sub LoadSystems()
Dim da As New SqlDataAdapter("COM_GET_SYSTEMS_SP", dbConn)
Dim ds As New DataSet
Dim dr As DataRow
da.Fill(ds, "Systems")
dr = ds.Tables("Systems").NewRow
dr(0) = 0
dr(1) = "All Emails"
ds.Tables("Systems").Rows.InsertAt(dr, 0)
SystemList.ValueMember = "id"
SystemList.DisplayMember = "name"
SystemList.DataSource = ds.Tables("Systems")
End Sub
Private Sub Loademails(ByVal systemID As Integer)
Dim da As New SqlDataAdapter("GetEmailMessages", dbConn)
da.SelectCommand.CommandType = CommandType.StoredProcedure
With da.SelectCommand.Parameters
If systemID <> 0 Then .Add("@SystemID", SqlDbType.Int).Value =
systemID
End With
Try
If Not ds.Tables("Emails") Is Nothing Then
ds.Tables.Remove("Emails")
da.Fill(ds, "Emails")
EmailDataGrid.DataSource = ds.Tables("Emails")
' EmailDataGrid.AllowSorting = False
EmailDataGrid.ReadOnly = True
Catch ex As Exception
Dim temp As String = ex.Message
End Try
End Sub
Private Sub SystemList_SelectedIndexChanged(ByVal sender As
System.Object, _
ByVal e As System.EventArgs) Handles
SystemList.SelectedIndexChanged
Loademails(sender.SelectedValue)
End Sub
**********************************************************************
Thanks,
Tom
(SystemList), it goes to the SelectedIndexChanged event which calls the
Loademails() function. I then call it again in the Form1Load function.
How do I get it not to call it in the SelectedIndexChanged from the
Form1Load function? Normally, I want it to call it but not when I initally
fill the ComboBox.
*********************************************************
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Call LoadSystems()
Call Loademails(0)
End Sub
Private Sub LoadSystems()
Dim da As New SqlDataAdapter("COM_GET_SYSTEMS_SP", dbConn)
Dim ds As New DataSet
Dim dr As DataRow
da.Fill(ds, "Systems")
dr = ds.Tables("Systems").NewRow
dr(0) = 0
dr(1) = "All Emails"
ds.Tables("Systems").Rows.InsertAt(dr, 0)
SystemList.ValueMember = "id"
SystemList.DisplayMember = "name"
SystemList.DataSource = ds.Tables("Systems")
End Sub
Private Sub Loademails(ByVal systemID As Integer)
Dim da As New SqlDataAdapter("GetEmailMessages", dbConn)
da.SelectCommand.CommandType = CommandType.StoredProcedure
With da.SelectCommand.Parameters
If systemID <> 0 Then .Add("@SystemID", SqlDbType.Int).Value =
systemID
End With
Try
If Not ds.Tables("Emails") Is Nothing Then
ds.Tables.Remove("Emails")
da.Fill(ds, "Emails")
EmailDataGrid.DataSource = ds.Tables("Emails")
' EmailDataGrid.AllowSorting = False
EmailDataGrid.ReadOnly = True
Catch ex As Exception
Dim temp As String = ex.Message
End Try
End Sub
Private Sub SystemList_SelectedIndexChanged(ByVal sender As
System.Object, _
ByVal e As System.EventArgs) Handles
SystemList.SelectedIndexChanged
Loademails(sender.SelectedValue)
End Sub
**********************************************************************
Thanks,
Tom