Public Class btnXLStoDBF Inherits ESRI.ArcGIS.Desktop.AddIns.Button 'Inherits System.Windows.Forms.Form 'Inherits can appear only once within a Class statement and can only specifiy one class Public m_myfrmXLStoDBF As frmXLStoDBF Public ReadOnly Property myfrmXLStoDBF() As frmXLStoDBF Get If IsNothing(m_myfrmXLStoDBF) Then m_myfrmXLStoDBF = New frmXLStoDBF Return m_myfrmXLStoDBF End Get End Property Protected Overrides Sub OnClick() 'This is the main subroutine that is initiated upon clicking a button in ESRI ArcMap Addin Call myfrmXLStoDBF.ReadXL() End Sub End Class Public Class frmXLStoDBF 'THIS IS THE MAIN FORM CLASS - There are two Panel Controls, Two Button Controls, and a DataGridView named dgvDatabase Inherits System.Windows.Forms.Form Public ReadOnly Property myfrmFieldAttributes() As frmFieldAttributes Get If IsNothing(m_myfrmFieldAttributes) Then m_myfrmFieldAttributes = New frmFieldAttributes Return m_myfrmFieldAttributes End Get End Property Private Sub btnReadExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadExcel.Click Call ReadXL() End Sub Private Sub btnFieldAttributes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFieldAttributes.Click myfrmFieldAttributes.Show() End Sub Public Sub ReadXL() 'Blah do stuff here End Sub End Class Public Class frmFieldAttributes 'THIS IS THE SECOND FORM CLASS - There are two Panel Controls, 6 Button Controls, and a DataGridView named dgvFieldAttributes Inherits System.Windows.Forms.Form Public m_myfrmXLStoDBF As frmXLStoDBF Public ReadOnly Property myfrmXLStoDBF() As frmXLStoDBF Get If IsNothing(m_myfrmXLStoDBF) Then m_myfrmXLStoDBF = New frmXLStoDBF Return m_myfrmXLStoDBF End Get End Property Private Sub btnGetHeadings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetHeadings.Click Call BlankAttributes() Dim ncol As Integer = myfrmXLStoDBF.dgvDataBase.ColumnCount - 1 '<--Problem occurs here. It returns 0 for ColumnCount: ncol = -1 Dim nrow As Integer = myfrmXLStoDBF.dgvDataBase.RowCount - 2 ReDim Headings(ncol) Dim row(4) For i = 0 To ncol Headings(i) = myfrmXLStoDBF.dgvDataBase.Columns(i).HeaderText row(0) = i row(1) = Headings(i) dgvFields.Rows.Add(row) Next i End Sub End Class
Solved! Go to Solution.
Public Class frmFieldAttributes 'THIS IS THE SECOND FORM CLASS - There are two Panel Controls, 6 Button Controls, and a DataGridView named dgvFieldAttributes Inherits System.Windows.Forms.Form Public m_myfrmXLStoDBF As frmXLStoDBF Public ReadOnly Property myfrmXLStoDBF() As frmXLStoDBF Get If IsNothing(m_myfrmXLStoDBF) Then m_myfrmXLStoDBF = New frmXLStoDBF Return m_myfrmXLStoDBF End Get End Property Private Sub btnGetHeadings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetHeadings.Click Call BlankAttributes() Dim ncol As Integer = myfrmXLStoDBF.dgvDataBase.ColumnCount - 1 '<--Problem occurs here. It returns 0 for ColumnCount: ncol = -1 Dim nrow As Integer = myfrmXLStoDBF.dgvDataBase.RowCount - 2 ReDim Headings(ncol) Dim row(4) For i = 0 To ncol Headings(i) = myfrmXLStoDBF.dgvDataBase.Columns(i).HeaderText row(0) = i row(1) = Headings(i) dgvFields.Rows.Add(row) Next i End Sub End Class