Solved

Confused on which events to use for UserControl?

Posted on 2014-01-13
6
181 Views
Last Modified: 2014-01-19
I have a Form that contains 2 tabs from a TabControl. On one of these tabs I have a User Control. What I'm trying to do is when the tab with the UC is the current tab, an event in the UC needs to fire so it can determine how to set certain properties of the UC and I'm not sure which event to use.

Thanks!
0
Comment
Question by:BlakeMcKenna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Crashman
ID: 39777695
You can use what event you wish,
you only must check if the activetab is tab1.
0
 

Author Comment

by:BlakeMcKenna
ID: 39777707
Where should I be checking?  Once that has been determined...how do I get into the UC?
0
 
LVL 8

Expert Comment

by:Crashman
ID: 39777820
can you explain a little more the situation, can you post the UC code?,

you can check here the tabcontrol events,
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BlakeMcKenna
ID: 39777838
Here are the UC Events & Code. It's pretty simple really.

Imports System.IO

Public Class FileIndicator

    Private BH As New BusinessLayer.CalBusiness
    Private EH As New ErrorHandling.ErrorHandler

    Private ID As Integer = 0

    Private blnLoaded As Boolean = False

    Private ofd As New OpenFileDialog
    '
    '
    '
    Private Sub LoadTheComboBox()
        Dim dt As New DataTable

        Try
            dt = BL.GetEquipCerts(gstrID, gEquipCode)

            If Not dt Is Nothing Then
                If dt.Rows.Count > 0 Then
                    cmbHistory.DataSource = Nothing
                    cmbHistory.DataSource = dt
                    cmbHistory.DisplayMember = "calDate"
                    cmbHistory.ValueMember = "id"
                    cmbHistory.SelectedIndex = -1
                End If
            End If

        Catch ex As Exception
            EH.strRetVal = "FileIndicator/LoadTheComboBox() - " & ex.Message & "~E"
        End Try
    End Sub
    '
    '
    '
    Private Sub FileIndicator_Load(sender As Object, e As EventArgs) Handles Me.Load
        Try
            cmbHistory.Visible = True
            blnLoaded = True

        Catch ex As Exception
            EH.strRetVal = "FileIndicator/FileIndicator_Load() - " & ex.Message & "~E"
        End Try
    End Sub
    '
    '
    '
    Private Sub btnAttachFile_Click(sender As Object, e As EventArgs) Handles btnAttachFile.Click
        Try
            Dim ofd As New OpenFileDialog
            Dim strFileName As String = ""

            EH.strRetVal = ""

            ofd.ShowDialog()

            If ofd.FileName.Length > 0 Then
                gfileByte = Nothing
                gfileByte = System.IO.File.ReadAllBytes(ofd.FileName)
            End If

        Catch ex As Exception
            EH.strRetVal = "FileIndicator/btnAttachFile_Click() - " & ex.Message & "~E"
        End Try
    End Sub
    '
    '
    '
    Private Sub cmbHistory_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbHistory.SelectedIndexChanged
        Try
            If blnLoaded Then
                If cmbHistory.SelectedIndex > -1 Then
                    ID = CType(cmbHistory.SelectedValue, Integer)
                End If
            End If

        Catch ex As Exception
            EH.strRetVal = "FileIndicator/cmbHistory_SelectedIndexChanged() - " & ex.Message & "~E"
        End Try
    End Sub
    '
    '
    '
    Private Sub OpenCertificate()
        Try

        Catch ex As Exception
            EH.strRetVal = "FileIndicator/OpenCertificate() - " & ex.Message & "~E"
        End Try
    End Sub
    '
    '
    '
    Private Sub FileIndicator_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged
        Try
            lblHistory.Visible = gblnAttachmentsExist
            cmbHistory.Visible = gblnAttachmentsExist

            If cmbHistory.Visible = True Then
                RectangleShape1.FillColor = Color.LimeGreen
                Label1.Text = "Attachments Exist"
                LoadTheComboBox()
            Else
                Label1.Text = "No Attachments"
                RectangleShape1.FillColor = Color.Red
            End If

        Catch ex As Exception
            EH.strRetVal = "FileIndicator_VisibleChanged() - " & ex.Message & "~E"
        End Try
    End Sub
End Class

Open in new window

0
 

Accepted Solution

by:
BlakeMcKenna earned 0 total points
ID: 39779325
I actually got it working now but still need to walk thru it and get a good understanding.

Thanks!
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 39791915
I got it working somehow. Not sure exactly how but I need to walk thru the code and get a better understanding of what happens under the circumstances.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question