473,385 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

MDI Applications using Toolbar control

Hi All,
I have an Windows Application in which I have an MDI form and some child
forms. I am assigning the parent window for the child forms using the code
frmTest1.mdiparent=me [ie, the mdimain form]

Now in the main window, I have menus through which I can open the desired
child form and I am using the following code to do so on click of each menu
item.

Dim frmChildForm as Form
If IsNothing(frmChildForm) Then
frmChildForm = New frmTest1
frmChildForm.MdiParent = Me
frmChildForm.Show()
End If

Now again in the child forms (say frmTest1), I have command buttons namely
cmdNew, cmdSave and cmdDelete wherein I have some functionality.

Like this I have other 15 child forms in my applications and based on the
menu selection, appropriate forms will be displayed.

Now in the toolbar that is placed in the mdimain, I have 4 buttons, namely
New, Save, Delete and Find buttons. Now on click of New button on toolbar,
cmdNew button functionality has to triggered for the activeform that is open.

I am using the following code to do so in the toolbar_ButtonClick event
Select Case eventArgs.button.Index
Case 1 'New Button
CType(MDIMain.ActiveForm, frmChildForm).cmdNew.PerformClick()
Case 2 'Save Button
CType(MDIMain.ActiveForm, frmTest1).cmdSave.PerformClick()
Case 3 'Delete Button
CType(MDIMain.ActiveForm, frmTest1).cmdDelete.PerformClick()
Case 4 'Find Button
MsgBox(Toolbar1.Buttons(4).Key)
End Select

Now if you can observe, for case statement 1, frmChildForm is giving me
compile time error as Type 'frmChildForm' is not defined. But the code in
case 2 is executing correctly. But the code in Case 2 is not generic.

Can anyone help me solve this issue. If you have any sample code or
materials that explains the solution for these type of issues, please let me
know.

Thanks & Regards
Sudhakara.T.P.
(su*********@hotmail.com)
Nov 21 '05 #1
1 1370
Sudhakara.T.P. wrote:
Hi All,
Dim frmChildForm as Form
If IsNothing(frmChildForm) Then
frmChildForm = New frmTest1
frmChildForm.MdiParent = Me
frmChildForm.Show()
End If

Select Case eventArgs.button.Index
Case 1 'New Button
CType(MDIMain.ActiveForm, frmChildForm).cmdNew.PerformClick()
Case 2 'Save Button
CType(MDIMain.ActiveForm, frmTest1).cmdSave.PerformClick()
Case 3 'Delete Button
CType(MDIMain.ActiveForm, frmTest1).cmdDelete.PerformClick()
Case 4 'Find Button
MsgBox(Toolbar1.Buttons(4).Key)
End Select

Now if you can observe, for case statement 1, frmChildForm is giving me
compile time error as Type 'frmChildForm' is not defined. But the code in
case 2 is executing correctly. But the code in Case 2 is not generic.

Can anyone help me solve this issue. If you have any sample code or
materials that explains the solution for these type of issues, please let me
know.

I would recommend defining a base form class that has the functions that
are applicable to all the derived forms. Then, derive those forms with
the specific frmTest1, frmTest2, and so forth. Then, when the toolbar
button is pressed, you need only test for the base form type that all
the other forms are derived from. Hope that helps.

Tom
Thanks & Regards
Sudhakara.T.P.
(su*********@hotmail.com)

Nov 21 '05 #2

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

Similar topics

0
by: Joe Helmick | last post by:
This one has me really stumped, so I thought I'd ask publicly. I was trying to take my ASP.NET web page "template" -- banner graphic, small navigation bar, and user feedback message area -- and...
15
by: Code Monkee | last post by:
How can the toolbar and menubar be hidden in IE? When opening the window via javascript I can specify 'toolbar=no,menubar=no', which works fine. However if the window already exists how can I...
52
by: Harlan Messinger | last post by:
Can you help me figure out what to do about popups? Sometimes we develop web applications where popups make very good sense for precisely the same reasons they make sense in traditional...
7
by: Andy Bates | last post by:
I have hopefully a simple problem in C#. I designed a form with a listview on left, vert splitter against that, then the remainder of the form from top to bottom: a listview, horiz splitter and...
0
by: I am Sam | last post by:
Ok whats wrong with my toolbar? When I debug I don't get an error message and the databinding is working correctly but the toolbar itself and the <iewc:ToolbarDropDownlist /> control isn't showing...
0
by: IkBenHet | last post by:
This error below happens sometimes when accessing the page. When you refresh the page it is ok. Please help. Server Error in '/' Application....
5
by: Stewart | last post by:
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box. I have found that when clicking on the Toolbar the focus in the binded text box does not leave. ...
6
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for...
1
by: Alfredo Barrientos | last post by:
Hi, I have a little trouble trying to assign a Toolbar control to another toolbar variable control. I am getting my forms controls with this: for (int j = 0; j <= frmChild.Controls.Count -...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.