473,508 Members | 2,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tabcontrol on an MDI form

Hey there kind folks. Maybe someone out there can tell me where I'm
going wrong here.

I have a winform MDI app with a parent form ("MDIHMI.vb") and a child
form ("frmEMSearch"). On frmEMSearch, is a tab control with 4 tab
pages; the first one (index 0) is called "tabEpiDef". I have a menu
bar across the top of MDHMI where one of the options should bring
frmEMSearch up if it's not already of course, and if it is, switch
over to the tabEpiDef tab page.

In coding the click event for the menu item, no matter what I do, I
cant seem to bring the first tab page to the front. It seems like
I've tried everything. None of these seem to work (individually, or
in groups)...
frmEMSearch.Controls("TabControl1").Controls("tabE piDef").BringToFront()
frmEMSearch.TabControl1.SelectedIndex = 0
newForm.TabControl1.SelectedIndex = 0

frmEMSearch.Controls("TabControl1").Controls("tabE piDef").Select()

frmEMSearch.Controls("TabControl1").Controls("tabE piDef").BringToFront()
frmEMSearch.TabControl1.SelectedIndex = 0
frmEMSearch.TabControl1.SelectedTab.BringToFront()
frmEMSearch.Controls("tabcontrol1").Select()
frmEMSearch.TabControl1.TabPages(0).Select()
frmEMSearch.TabControl1.TabPages(0).Show()
frmEMSearch.TabControl1.TabPages(0).BringToFront()
newForm.tabEpiDef.Select()
newForm.tabEpiDef.BringToFront()
newForm is instantiated immediately before all the above with...

Dim newForm As New frmEMSearch

Is there some sort of special way I'm not aware of to refer to a child
form in an MDI app? Can anyone give me a clue as to what direction I
should be looking to for an answer to this seemingly easy task?

Thanks VERY much in advance...Ooogy

Jun 27 '08 #1
7 3188
"Ooogy" <oo********@yahoo.comschrieb
Hey there kind folks. Maybe someone out there can tell me where I'm
going wrong here.

I have a winform MDI app with a parent form ("MDIHMI.vb") and a
child form ("frmEMSearch"). On frmEMSearch, is a tab control with 4
tab pages; the first one (index 0) is called "tabEpiDef". I have a
menu bar across the top of MDHMI where one of the options should
bring frmEMSearch up if it's not already of course, and if it is,
switch over to the tabEpiDef tab page.

In coding the click event for the menu item, no matter what I do, I
cant seem to bring the first tab page to the front. It seems like
I've tried everything. None of these seem to work (individually, or
in groups)...
frmEMSearch.Controls("TabControl1").Controls("tabE piDef").BringToFront()
frmEMSearch.TabControl1.SelectedIndex = 0
newForm.TabControl1.SelectedIndex = 0

frmEMSearch.Controls("TabControl1").Controls("tabE piDef").Select()

frmEMSearch.Controls("TabControl1").Controls("tabE piDef").BringToFront()
frmEMSearch.TabControl1.SelectedIndex = 0
frmEMSearch.TabControl1.SelectedTab.BringToFront()
frmEMSearch.Controls("tabcontrol1").Select()
frmEMSearch.TabControl1.TabPages(0).Select()
frmEMSearch.TabControl1.TabPages(0).Show()
frmEMSearch.TabControl1.TabPages(0).BringToFront()
newForm.tabEpiDef.Select()
newForm.tabEpiDef.BringToFront()
newForm is instantiated immediately before all the above with...

Dim newForm As New frmEMSearch

Is there some sort of special way I'm not aware of to refer to a
child form in an MDI app? Can anyone give me a clue as to what
direction I should be looking to for an answer to this seemingly
easy task?

Thanks VERY much in advance...Ooogy

newform.tabcontrol1.selectedtab = newform.tabepidef

I'd put it inside frmEMSearch because both (explicit) references to
newform can be omitted.
Armin

Jun 27 '08 #2
>
newform.tabcontrol1.selectedtab = newform.tabepidef

Armin, thanks for the effort but unfortunately, still no luck.
Neither:

newForm.TabControl1.SelectedTab = newForm.tabEpiDef

or...

newForm.TabControl1.SelectedTab = newForm.tabEpiDef
newForm.TabControl1.SelectedTab.BringToFront()

or even...

newForm.TabControl1.SelectedTab =
newForm.Controls("TabControl1").Controls("tabEpiDe f")

....seem to work. It just stays at the current tab and doesn't switch
over to tabEpiDef. Any other ideas for me to try?

Thanks...Ooogy
Jun 27 '08 #3
"Ooogy" <oo********@yahoo.comschrieb
>

newform.tabcontrol1.selectedtab = newform.tabepidef


Armin, thanks for the effort but unfortunately, still no luck.
Neither:

newForm.TabControl1.SelectedTab = newForm.tabEpiDef

or...

newForm.TabControl1.SelectedTab = newForm.tabEpiDef
newForm.TabControl1.SelectedTab.BringToFront()

or even...

newForm.TabControl1.SelectedTab =
newForm.Controls("TabControl1").Controls("tabEpiDe f")

...seem to work. It just stays at the current tab and doesn't
switch over to tabEpiDef. Any other ideas for me to try?
You wrote "where one of the options should bring frmEMSearch up if it's
not already of course"
Therefore I assumed that you create a new Form (by executing "New
frmEMSearch") only if it has not been created yet. Is this assumption
correct? I guess, you create a new Form each time even if there is
already one visible.
Armin

Jun 27 '08 #4
Exactly...here's what's not working...
Private Sub EpisodeDefinitionToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
EpisodeDefinitionToolStripMenuItem.Click
Dim newForm As New frmEMSearch()
newForm.MdiParent = Me
If IsNothing(newForm) Then
newForm.ShowDialog()
Else
If gCurrentTabIndex <0 Then
newForm.TabControl1.SelectedTab = newForm.tabEpiDef
End If
End If
End Sub
gCurrentTabIndex is set to the new tab index on TabControl1's
selectedindexchanged event.

Is my problem perhaps creating the new frmEMSearch even if it's
already there? How else other than the "If IsNothing(newForm)" would
I handle testing whether frmEMSearch currently is present? There are
of course other forms available to MDHMI to be a child and showing.

Thanks...Ooogy
Jun 27 '08 #5
On Wed, 16 Apr 2008 09:28:41 -0700 (PDT), Ooogy <oo********@yahoo.com>
wrote:
>Exactly...here's what's not working...
Private Sub EpisodeDefinitionToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
EpisodeDefinitionToolStripMenuItem.Click
Dim newForm As New frmEMSearch()
newForm.MdiParent = Me
If IsNothing(newForm) Then
newForm.ShowDialog()
Else
You are always creating a new form. You create a new frmEMSearch and
put its reference in newForm, and you set the new form's MdiParent
property. You then check the variable newForm for Nothing, but it
can't be Nothing because you just used it to set a property.

What I would do is create a class level property:

Private emSearch as frmEMSearch = Nothing

then change the code above to:

If emSearch Is Nothing Then
emSearch = New frmEMSearch
emSearch.MdiParent = Me
End If

If gCurrentTabIndex <0 Then
emSearcg.TabControl1.SelectedTab = emSearch.tabEpiDef
End If

emSearch.ShowDialog()
Jun 27 '08 #6
"Ooogy" <oo********@yahoo.comschrieb
Exactly...here's what's not working...
Private Sub EpisodeDefinitionToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
EpisodeDefinitionToolStripMenuItem.Click
Dim newForm As New frmEMSearch()
newForm.MdiParent = Me
If IsNothing(newForm) Then
- newForm can never be nothing because you've just assigned a new object
to the variable
- General hint: "... Is Nothing" is shorter than calling a function
(IsNothing). Minor issue only.
newForm.ShowDialog()
Really Showdialog? In this case you could not use the menu again while
the modal form is shown.

Else
If gCurrentTabIndex <0 Then
newForm.TabControl1.SelectedTab = newForm.tabEpiDef
End If
End If
End Sub
gCurrentTabIndex is set to the new tab index on TabControl1's
selectedindexchanged event.

Is my problem perhaps creating the new frmEMSearch even if it's
already there? How else other than the "If IsNothing(newForm)"
would I handle testing whether frmEMSearch currently is present?
There are of course other forms available to MDHMI to be a child and
showing.

That's how I'd do it:
All in Class hdihmi:

private frmEMSearch as frmEMSearch

Private Sub EpisodeDefinitionToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
EpisodeDefinitionToolStripMenuItem.Click

if frmEMSearch is nothing then
frmEMSearch = New frmEMSearch()
addhandler frmEMSearch.formclosed,addressof OnEMSearchClosed
frmEMSearch.mdiparent = me
frmEMSearch.show
else
frmEMSearch.Activate

frmEMSearch.TabControl1.SelectedTab = frmEMSearch.tabEpiDef 'see
notes below
End Sub

protected overriadable sub OnEMSearchClosed

frmEMSearch = Nothing

end sub

However, I still don't understand how 'Showdialog' fits in your code.
I'm not sure /when/ you want to activate the TabPage. Only when the Form
is shown or also if it is reactivated?
Armin

Jun 27 '08 #7
Jack / Armin -

Got things working now as they should. For a while there, I was
getting a duplicate copy of frmEMSearch showing over the original; but
only the first time I clicked the menu item. After that, the new form
would switch to the proper tab as expected. Resolved that by setting
EMSearch to the initial "New frmEMSearch" call in MDIHMI's load event.

Thanks very much for the help...Ooogy
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2338
by: Francois Vanderseypen | last post by:
Can someone tell me why you cannot drag something onto a tabcontrol with zero tabpages? I have a kind of 'docking' interface and relies heavily on GDI+, a screenshot is available here: ...
8
15642
by: Aaron Ackerman | last post by:
If I am expanding (maximizing a form how do I maximize the tab control along with it?
9
3440
by: Michael Turner | last post by:
Hi Guys Having problem with the tab control, I need to set the background color to something different than the standard, I have found code on the web and now can redraw the tabpage buttons so...
2
1886
by: Aspnot | last post by:
I have a TabControl that is on a form that is bound to a DataSet. I bind the dataset to the form in the Form_Load event. The TabControl has 2 TabPages. The first TabPage contains a button and a...
1
4073
by: vooose | last post by:
Consider adding a TabPage with size=(300,300) to a TabControl, then calling tabControl.ClientSize=tabPage.Size; You would think tabControl.Size must now be BIGGER than tabControl.ClientSize...
2
3338
by: Simon Verona | last post by:
I have a few hundred forms in my application. All are based on a custom base form class. I decided that I wanted to globally change the look and feel of many of the controls in my application -...
8
6362
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
2
2617
by: Richard Carpenter | last post by:
I have a four-page tabcontrol with a gridview on each page. I have the primary key column of each gridview set to hidden (visible = false), but it still shows up on all but the first page. Anyone...
0
1400
by: bertie78 | last post by:
Hi all, New poster here! I'm having some difficulty updating a tabcontrol cross-threads. The general idea is : the main thread is the owner of the tab control and the form controls. However, due...
2
2103
by: Jamey | last post by:
Ran into an inconvenience with TabControls yesterday. I found a partial explanation from Allen Browne on the MS message boards explaining when it happens, but not why. I thought Stephen Lebans...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.