Windows Forms event problems with inherited form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

if I instantiate 2 forms from one base class, will control events on both
forms be recognized?

This is what we are doing, in our VB.NET Project we have an MDI form, and a
child form class called frmConfigBrowser.

We instantiate this base class twice, using declarations like this in the
MDI form:
private withevents frmConfigEditor as frmConfirgBrowser
private withevents frmConfigBrowser1 as frmConfirgBrowser

When the user clicks the menu item to open a data file for editing, we
instantiate the first variable, when they select to open a file for reading,
we instantiate the second variable.

But form events are only recognized for the first one we load... so
clicking a listbox on the first one changes another listbox, but a click on
the listbox of the second form loaded is ignored.

Any advice or help would be appreciated - I am new to Windows Forms/.NET and
this is killing us...

thanks

Philip
 
Philip,
I wanted to reply to this. Could you show us the code that instantiates the
forms?

DWS
 
Hi,
for the Read-Only instance of the form it is like this:

m_frmConfigBrowser1 = New frmConfigBrowser
Me.sbStatus.Panels(0).Text = "Loading from Repository object..."
With m_frmConfigBrowser1
.MdiParent = Me
.ParentStatus = Me.sbStatus
.Visible = False
.BrowserRole = frmConfigBrowser.BrowserRoleEnum.View
.LedgerObject.XMLConfigFile =
m_objRepositoryObject.getSpecificVersion(True)
Me.mnuView.Visible = True
.LedgerObject.FundNoteFilter =
"[boolean(descendant::Note[@status!='del'])]"
.LedgerObject.TranTypeNoteFilter =
"[boolean(descendant::Note[@status!='del'])]"
.LedgerObject.MappingNoteFilter =
"[boolean(descendant::Note[@status!='del'])]"
Me.sbStatus.Panels(0).Text = "Refresh Funds view..."
.refreshFunds()
.LedgerReadOnly = True
Me.Cursor = Cursors.Default
.Visible = True
.Show()
.Text = "[READ-ONLY] Browse Config Data (Version: " &
..LedgerObject.ConfigFileVersion & " )"
m_intBrowseChildWinCount = m_intBrowseChildWinCount + 1
End With

and for the Editing instance of the form it is like this:

m_frmConfigEditor = New frmConfigBrowser

Me.Cursor = Cursors.WaitCursor

With m_frmConfigEditor
.MdiParent = Me
.ParentStatus = Me.sbStatus
.AllowDrop = True
.Visible = False
.BrowserRole = frmConfigBrowser.BrowserRoleEnum.Edit
.LedgerObject.XMLConfigFile =
m_objRepositoryObject.getSpecificVersion(False)
Me.mnuView.Visible = True
.LedgerObject.FundNoteFilter =
"[boolean(descendant::Note[@status!='del'])]"
.LedgerObject.TranTypeNoteFilter =
"[boolean(descendant::Note[@status!='del'])]"
.LedgerObject.MappingNoteFilter =
"[boolean(descendant::Note[@status!='del'])]"
Me.sbStatus.Panels(0).Text = "Refresh funds view..."
.refreshFunds()
.LedgerReadOnly = False
Me.Cursor = Cursors.Default
.Visible = True
.Show()
.Text = "Edit Config Data (Version: " & .LedgerObject.ConfigFileVersion
& " )"
.Activate()
End With

It is really strange, we get events on the first form loaded (listbox click,
right-click etc) but not on the second...

Thanks for any help

Philip
 
Back
Top