Can you close an instance of a Form outside of the Form?

cesarfrancisco

Active member
Joined
Apr 3, 2007
Messages
33
Programming Experience
Beginner
VB.NET:
Option Strict On
Public Class ClothingDataGridView

   Private Sub ClothingDataGridViewl_Load(ByVal sender As System.Object, ByVal e As 
   System.EventArgs) Handles MyBase.Load
           Me.Table2TableAdapter.FillByClothing(Me.HOEXDBDataSet.Table2)
    End Sub

    Public entryform2 As New ClothingForm

    Private Sub Table2DataGridView_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles Table2DataGridView.CellMouseDoubleClick

  If Table2DataGridView.CurrentRow.IsNewRow = True Or e.RowIndex = -1 Then
     Exit Sub
  Else
     entryform2.Show()

                 entryform2.TextBox9.Text = Table2.DataGridView  _
     .Rows(e.RowIndex).Cells(0).Value.ToString   

     entryform2.Table2TableAdapter.FillByCloth(entryform2. _
     HomeExpenseDataSet.Table2, Integer.Parse(entryform2.TextBox9.Text))


     Me.Close()

            End If
      End Sub
End Class
---------------------------------

This is a DataGridView Form where the user can select a row by DoubleClicking on the row. The row's Key is then passed to the Data Entry Form (Clothing) to be filled with the row's data. Purpose: modify or delete a datarow.


The hierarchical order of these form:
Form1 > from this Form all the different Data Entry Forms open (like Shoes, Travel, etc.)
Form2, 3, 4, 5, 6, 7, etc are these Data Entry Forms.
From Forms (2, 3, 4, 5, 6, 7, etc) is possible to open one DataGridView Form corresponding to them. Form2 has one DataGridView, For3 has a DataGridView, and so on.


I would like to be able to close the instance of the ClothingForm (entryform2) created in ClothingDataGridView from Form1.

Is this even possible?
 
Last edited by a moderator:
I used both your solution.
1. I had - before you came in - a long list populated with EntryForm.Close() for each one of the Forms.
2. Why I was creating instances at all? (supposedly that was the only way to pass data from one Form to another.)

What amaze me, that I am amazed when I realize how stupid I am.
John, thanks for your patience. I did not deserve it.

P.S. I am working on a calculator program now. I am going on with it with the same convoluted way (the Cesar way) until I am amazed again.
 
Back
Top