473,659 Members | 2,609 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.Con trols("TabContr ol1").Controls( "tabEpiDef").Br ingToFront()
frmEMSearch.Tab Control1.Select edIndex = 0
newForm.TabCont rol1.SelectedIn dex = 0

frmEMSearch.Con trols("TabContr ol1").Controls( "tabEpiDef").Se lect()

frmEMSearch.Con trols("TabContr ol1").Controls( "tabEpiDef").Br ingToFront()
frmEMSearch.Tab Control1.Select edIndex = 0
frmEMSearch.Tab Control1.Select edTab.BringToFr ont()
frmEMSearch.Con trols("tabcontr ol1").Select()
frmEMSearch.Tab Control1.TabPag es(0).Select()
frmEMSearch.Tab Control1.TabPag es(0).Show()
frmEMSearch.Tab Control1.TabPag es(0).BringToFr ont()
newForm.tabEpiD ef.Select()
newForm.tabEpiD ef.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 3193
"Ooogy" <oo********@yah oo.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.Con trols("TabContr ol1").Controls( "tabEpiDef").Br ingToFront()
frmEMSearch.Tab Control1.Select edIndex = 0
newForm.TabCont rol1.SelectedIn dex = 0

frmEMSearch.Con trols("TabContr ol1").Controls( "tabEpiDef").Se lect()

frmEMSearch.Con trols("TabContr ol1").Controls( "tabEpiDef").Br ingToFront()
frmEMSearch.Tab Control1.Select edIndex = 0
frmEMSearch.Tab Control1.Select edTab.BringToFr ont()
frmEMSearch.Con trols("tabcontr ol1").Select()
frmEMSearch.Tab Control1.TabPag es(0).Select()
frmEMSearch.Tab Control1.TabPag es(0).Show()
frmEMSearch.Tab Control1.TabPag es(0).BringToFr ont()
newForm.tabEpiD ef.Select()
newForm.tabEpiD ef.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.tabcont rol1.selectedta b = newform.tabepid ef

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

Jun 27 '08 #2
>
newform.tabcont rol1.selectedta b = newform.tabepid ef

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

newForm.TabCont rol1.SelectedTa b = newForm.tabEpiD ef

or...

newForm.TabCont rol1.SelectedTa b = newForm.tabEpiD ef
newForm.TabCont rol1.SelectedTa b.BringToFront( )

or even...

newForm.TabCont rol1.SelectedTa b =
newForm.Control s("TabControl1" ).Controls("tab EpiDef")

....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********@yah oo.comschrieb
>

newform.tabcont rol1.selectedta b = newform.tabepid ef


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

newForm.TabCont rol1.SelectedTa b = newForm.tabEpiD ef

or...

newForm.TabCont rol1.SelectedTa b = newForm.tabEpiD ef
newForm.TabCont rol1.SelectedTa b.BringToFront( )

or even...

newForm.TabCont rol1.SelectedTa b =
newForm.Control s("TabControl1" ).Controls("tab EpiDef")

...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 EpisodeDefiniti onToolStripMenu Item_Click(ByVa l sender As
System.Object, ByVal e As System.EventArg s) Handles
EpisodeDefiniti onToolStripMenu Item.Click
Dim newForm As New frmEMSearch()
newForm.MdiPare nt = Me
If IsNothing(newFo rm) Then
newForm.ShowDia log()
Else
If gCurrentTabInde x <0 Then
newForm.TabCont rol1.SelectedTa b = newForm.tabEpiD ef
End If
End If
End Sub
gCurrentTabInde x is set to the new tab index on TabControl1's
selectedindexch anged event.

Is my problem perhaps creating the new frmEMSearch even if it's
already there? How else other than the "If IsNothing(newFo rm)" 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********@yah oo.com>
wrote:
>Exactly...here 's what's not working...
Private Sub EpisodeDefiniti onToolStripMenu Item_Click(ByVa l sender As
System.Objec t, ByVal e As System.EventArg s) Handles
EpisodeDefinit ionToolStripMen uItem.Click
Dim newForm As New frmEMSearch()
newForm.MdiPare nt = Me
If IsNothing(newFo rm) Then
newForm.ShowDia log()
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.MdiPar ent = Me
End If

If gCurrentTabInde x <0 Then
emSearcg.TabCon trol1.SelectedT ab = emSearch.tabEpi Def
End If

emSearch.ShowDi alog()
Jun 27 '08 #6
"Ooogy" <oo********@yah oo.comschrieb
Exactly...here' s what's not working...
Private Sub EpisodeDefiniti onToolStripMenu Item_Click(ByVa l sender As
System.Object, ByVal e As System.EventArg s) Handles
EpisodeDefiniti onToolStripMenu Item.Click
Dim newForm As New frmEMSearch()
newForm.MdiPare nt = Me
If IsNothing(newFo rm) 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.ShowDia log()
Really Showdialog? In this case you could not use the menu again while
the modal form is shown.

Else
If gCurrentTabInde x <0 Then
newForm.TabCont rol1.SelectedTa b = newForm.tabEpiD ef
End If
End If
End Sub
gCurrentTabInde x is set to the new tab index on TabControl1's
selectedindexch anged event.

Is my problem perhaps creating the new frmEMSearch even if it's
already there? How else other than the "If IsNothing(newFo rm)"
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 EpisodeDefiniti onToolStripMenu Item_Click(ByVa l sender As
System.Object, ByVal e As System.EventArg s) Handles
EpisodeDefiniti onToolStripMenu Item.Click

if frmEMSearch is nothing then
frmEMSearch = New frmEMSearch()
addhandler frmEMSearch.for mclosed,address of OnEMSearchClose d
frmEMSearch.mdi parent = me
frmEMSearch.sho w
else
frmEMSearch.Act ivate

frmEMSearch.Tab Control1.Select edTab = frmEMSearch.tab EpiDef 'see
notes below
End Sub

protected overriadable sub OnEMSearchClose d

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
2342
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: http://netron.sourceforge.net/Biotron3Shot.jpg You can move tab pages in the different panes, unless it's totally empty (TabCount=0). Is there an alternative? Thanks a lot,
8
15661
by: Aaron Ackerman | last post by:
If I am expanding (maximizing a form how do I maximize the tab control along with it?
9
3453
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 the are set to the right color, I can obviously change the tabpage colour but I am left with a grey top edge(Where there are no buttons) when the background of the form is changed any ideas on what I can do? Mike.
2
1893
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 textbox. Scenario 1: I call BindingContext(ds.TableName).AddNew(), then I click the button and that populates some text into the textbox on the first tab. Then I switch over to Tab2 and back to Tab1. The text that was programatically inserted...
1
4085
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 to accomadate room for the tabs and borders. In fact they are the same size! Compare this to adding a Panel to a Form. Form.Size would be slightly
2
3345
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 - including the tab control. I did this by writing a component that I attached to the form. The component has a "Start" function which takes the form as a paramater. This cycles through all the controls on the form, changes some of the properties...
8
6376
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 any feasible solution, i need to use a checked listbox which also has same flickering problem on resize. Thanks & Regards
2
2629
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 else see this behavior? How might I correct it?
0
1411
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 to the vast amount of data to populate listviews within the tabs, I have created a worker thread (an implementation of a BackgroundWorker) to form the data and populate a tabcontrol 'offline', so that it doesn't interfer with (i.e freeze) the UI. ...
2
2113
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 (who's done a little work with this for his multi-colored listbox class), or someone else might've figured this out. Here's the scenario: DBs created on Windows XP using A2K7 are apparently incapable of displaying TabControl transparency....
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8539
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7360
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4342
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2759
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 we have to send another system
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.