Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Error: X is not declared. It may be inaccessible due to its protection level.

Posted on 2012-08-29
3
Medium Priority
?
2,639 Views
Last Modified: 2012-08-29
Hi Experts,

I have struck thess errors:

Error      1      'DataGridView_HighlightOneRowOnly' is not declared. It may be inaccessible due to its protection level.      D:\Dev-Ver6.0\VB.NET\CIRCLY60\VB.NET\frmTrafficSpectrum.vb      32      14      Explorer Prototype
Error      2      'DataGridView_HighlightRowWithCellEqualsString' is not declared. It may be inaccessible due to its protection level.      D:\Dev-Ver6.0\VB.NET\CIRCLY60\VB.NET\frmTrafficSpectrum.vb      35      14      Explorer Prototype

The code is shown below.

DataGridView_HighlightOneRowOnly and DataGridView_HighlightRowWithCellEqualsString are subs that are called from frmTrafficSpectrum and defined in modDataGridView.

Regards,
Leigh

Here is frmTrafficSpectrum.vb:
Imports System.Data.OleDb

Public Class frmTrafficSpectrum
    Dim boolFormLoading As Boolean
    Private Sub frmTrafficSpectrum_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'LOADSDataSet2.TrafficSpectrumComponents' table. You can move, or remove it, as needed.
        Me.TrafficSpectrumComponentsTableAdapter.Fill(Me.LOADSDataSet2.TrafficSpectrumComponents)
        'TODO: This line of code loads data into the 'LOADSDataSet.TrafficSpectrum' table. You can move, or remove it, as needed.
        Me.TrafficSpectrumTableAdapter.Fill(Me.LOADSDataSet.TrafficSpectrum)
        boolFormLoading = True
        'original code from here:
        '
        '   How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls
        '       http://msdn.microsoft.com/en-us/library/c12c1kx4.aspx
        '
        ' D:\Mincad Intranet\software\VB.NET\Sample Code\Database\DataGridView - Master Detail Example from Microsoft
        '' Bind the DataGridView controls to the BindingSource
        '' components and load the data from the database.
        'masterDataGridView.DataSource = masterBindingSource
        'detailsDataGridView.DataSource = detailsBindingSource
        GetData()

        '' Resize the master DataGridView columns to fit the newly loaded data.
        'masterDataGridView.AutoResizeColumns()

        '' Configure the details DataGridView so that its columns automatically
        '' adjust their widths when the data changes.
        'detailsDataGridView.AutoSizeColumnsMode = _
        '    DataGridViewAutoSizeColumnsMode.AllCells

        'Highlight one row only
        Call DataGridView_HighlightOneRowOnly(dgvSpectrum) '20120829

        'highlight row given by SpectrumID (20120814)
        Call DataGridView_HighlightRowWithCellEqualsString(dgvSpectrum, SpectrumID, boolFormLoading) '20120829

    End Sub
    Private Sub GetData()

        'original code from here:
        '
        '   How to: Create a Master/Detail Form Using Two Windows Forms DataGridView Controls
        '       http://msdn.microsoft.com/en-us/library/c12c1kx4.aspx
        '
        ' D:\Mincad Intranet\software\VB.NET\Sample Code\Database\DataGridView - Master Detail Example from Microsoft



        Try

            Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
            "Data Source=" + strDataPath + _
            "\LOADS.mdb;Persist Security Info=False"
            Dim connection As OleDbConnection = New OleDbConnection(strConn)
            connection.Open()

            ' Create a DataSet.
            Dim data As New DataSet()
            data.Locale = System.Globalization.CultureInfo.InvariantCulture

            ' Add data from the TrafficSpectrum table to the DataSet.
            Dim masterDataAdapter As _
                New OleDbDataAdapter("select * from TrafficSpectrum", connection)
            masterDataAdapter.Fill(data, "TrafficSpectrum")

            ' Add data from the TrafficSpectrumComponents table to the DataSet.
            Dim detailsDataAdapter As _
                New OleDbDataAdapter("select * from TrafficSpectrumComponents", connection)
            detailsDataAdapter.Fill(data, "TrafficSpectrumComponents")

            ' Establish a relationship between the two tables.
            Dim relation As New DataRelation("TrafficSpectrumTrafficSpectrumComponents", _
                data.Tables("TrafficSpectrum").Columns("TrafficSpectrumID"), _
                data.Tables("TrafficSpectrumComponents").Columns("TrafficSpectrumID"))
            data.Relations.Add(relation)

            ' Bind the master data connector to the TrafficSpectrum table.
            TrafficSpectrumBindingSource.DataSource = data
            TrafficSpectrumBindingSource.DataMember = "TrafficSpectrum"

            ' Bind the details data connector to the master data connector,
            ' using the DataRelation name to filter the information in the 
            ' details table based on the current row in the master table. 
            TrafficSpectrumComponentsBindingSource.DataSource = TrafficSpectrumBindingSource
            TrafficSpectrumComponentsBindingSource.DataMember = "TrafficSpectrumTrafficSpectrumComponents"
        Catch ex As OleDb.OleDbException
            MessageBox.Show("To run this example, replace the value of the " & _
                "connectionString variable with a connection string that is " & _
                "valid for your system.")
        End Try

    End Sub


    Private Sub dgvSpectrum_SelectionChanged(sender As Object, e As System.EventArgs) Handles dgvSpectrum.SelectionChanged

        'Capture the ID of the selected row (assumed to be first column)

        'loop through every item in DataGridView
        For Each SelectedRow As DataGridViewRow In dgvSpectrum.SelectedRows()

            If Not boolFormLoading Then
                SpectrumID = SelectedRow.Cells(0).Value.ToString '20120817
            End If
        Next
    End Sub

End Class

Open in new window


Here is modDataGridView.frm:

Public Module modDataGridView
    Public Sub DataGridView_HighlightRowWithCellEqualsString(dgv As DataGridView, strSearch As String, boolFormLoading As Boolean)

        'highlight row given by strSearch (assumes we are searching first column)

        For i As Integer = 0 To dgv.Rows.Count - 1
            If dgv.Item(0, i).Value = strSearch Then
                dgv.CurrentCell = dgv.Item(0, i)
                Exit For
            End If
        Next
        boolFormLoading = False

    End Sub
    Public Sub DataGridView_HighlightOneRowOnly(dgv As DataGridView)

        'Highlight one row only

        With dgv
            .SelectionMode = DataGridViewSelectionMode.FullRowSelect
            .MultiSelect = False
        End With

    End Sub

End Module

Open in new window

0
Comment
Question by:LeighWardle
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
mvdeveloper earned 2000 total points
ID: 38344522
Try prefacing the call with the name of the module so it knows where to find it.

modDataGridView.DataGridView_HighlightOneRowOnly(dgvSpectrum)
0
 
LVL 1

Author Comment

by:LeighWardle
ID: 38344815
Weird - The problem was that my file modDataGridView.frm mistakenly had the extension .frm.

It compiled without error as soon as I changed the extension to  .vb.
0
 
LVL 5

Expert Comment

by:mvdeveloper
ID: 38344860
Glad to know you're back on track.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

578 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