Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2007, 05:59 PM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default attaching form to menu item

So far, I have not been able to figure out how to attach a form to the menu item I created for it.
What am I missing?

Thanks,
Karen

 
Old January 18th, 2007, 04:48 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

A little more verbose would be nice. Windows app? Web app? What do you mean by "attach?"

Keep in mind that no one knows what you have in mind unless you [i]say[/] what you have in mind... It is really hard to do much with what you have said so far.
 
Old January 19th, 2007, 11:56 AM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

Brian, et al,
sorry,
I am new to Windows development and am not explaining things well.

I have multiple forms and need to be able to execute them from the menus that I created.

I also want to have a generic form that can be used to for multiple different tables for editing lookup values.
Creating the menus and the forms were the easy parts, hooking it all together is what I'm not sure how to accomplish.

I know it can be done, I just don't know enough VB to do it.

Karen

 
Old January 19th, 2007, 12:05 PM
Authorized User
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196
Default

First, I'm assuming that you are designing a Windows Forms application.

Let's say that you have a form called frmTools created in your project and you want to run that form from your menu. In the section of the menu code that you want to open this form you might call it as follows:

'* Create a new instance of your form
dim frmTools as new frmTools

'* Load your form as a "Non-Modal" form.
frmTools.show

'* or

'* Load your form as a "Modal" form.
frmTools.ShowDialog

Using just "Show" will display the form "Non-Modal" (you can access other parts of your application while this form is displayed).

Using "ShowDialog" will display the form "Modal" (you cannot access any other part of your application until you close this form).




Best Regards,
Earl Francis
 
Old January 19th, 2007, 12:07 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

All of your menu items have a Click event associated with them so your method might look something like this:

VB:
Private Sub menuItem6_Click(ByVal Sender as Object, ByVal e as System.EventArgs)

End Sub

C#
private void menuItem6_Click(object sender, System.EventArgs e)
{

}

From here is where you will call your other forms so something like this:

VB:
Private Sub menuItem6_Click(ByVal Sender as Object, ByVal e as System.EventArgs)
 Dim frm as New form2()
 frm.Show()
End Sub

C#
private void menuItem6_Click(object sender, System.EventArgs e)
{
    form2 frm = new form2();
        frm.Show();
}

Obviously form2 will be the name of the Form you are wanting to work with. In so far as your question about generic forms that handle multiple different secnarios I would suggest overloading your constructors so that you can know how the generic form should be set up so:

Dim frm as New form2(<value>)
Dim frm as New form2(<value>, <value>)
Dim frm as New form2(<value>, <value>, <value>)

etc.

Hope that helps

================================================== =========
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
View IE Favorites in a Menu Item. jpool Visual Studio 2005 0 October 3rd, 2008 11:51 AM
right click on a menu item chuckcottle C++ Programming 3 May 14th, 2007 10:34 AM
cannot add a new item to this menu ... paulmarshall General .NET 0 April 18th, 2007 03:03 PM
how create menubar, menu, menu item in xsl vijayanmsc XSLT 1 June 5th, 2006 06:43 AM
Menu Help in statusbar at mousemove over Menu item Kaustav VB Components 1 September 14th, 2005 09:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.