Wrox Programmer Forums
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 December 6th, 2005, 07:07 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default ActiveForm

Hi,

I'm converting a VB 6.0 project to VB.Net.

   In my VB 6.0 project, I have a toolbar in MDI form and I'm using that to every child form instead of adding a toolbar to every child form.

   I have a Sub called "Perform_ButtonClick" in every child form and I'm calling that when a button is pressed in the toolbar according to the form loaded on MDI form.

   In MDI form button click event I'm calling the active forms's "Perform_ButtonClick" Sub so it'll go to relevant form's "Perform_ButtonClick" Sub.

   So how can I implement this in VB.Net? what can I use in VB.Net instead of "ActiveForm" in VB 6.0 ?

Cheers,

   nalla


__________________
nalaka hewage
http://nalakahewage.blogspot.com
 
Old December 8th, 2005, 04:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Hi Nalla,

U tried using ActiveMdiChild ?

Regards
Ankur Verma
 
Old December 9th, 2005, 03:03 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default

Hi,
At last I got a reply after a long time.ThanX.
yes ,I tried ActiveMdiChild and ActiveForm bot but it shows(highlighted) a systax error.

ActivateMdiChild.Perform_ButtonClick("New")
ActiveForm.Perform_ButtonClick("New")

I tried those 2 but it highlighed a systax error as,
'Perform_ButtonClick' is not a member of 'System.Windows.Forms.Form'

 
Old December 9th, 2005, 03:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

No no, VB .NET works a bit differently. Compiler is right in what it says. 'Perform_ButtonClick'
indeed is not the way to go about as it doesnt exist in .NET.

Raising an event is done a bit differently in VB .NET.

Read a bit about events and how they work in .NET. I've been following your posts, and I belive
you have a good experiance of programming in general so if you just figure out how events
work in VB .NET you would be able to solve your problem yourself. And this information
would come handy with whatever you do in .NET as events work in the same way every where
regardless of the language you r working with in .NET.

Regards
Ankur Verma
 
Old December 9th, 2005, 03:59 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default

Hi,

Perform_ButtonClick is not an event it's a Sub(subroutine) in every form.Let me explain you bit more.

   I have a subroutine called "Perform_ButtonClick" in every form and When "ToolBar_ButtonClick" event is fired in MDI form (when clicked the toolbar in MDI form), it calls the "Perform_ButtonClick" subroutine of the form loaded on MDI form(active form). so it'll go to the relevant form's "Perform_ButtonClick" Subroutime and handles the MDI form's "ToolBar_ButtonClick" event.
   If I create and object from a form and calls that object's Perform_ButtonClick" subroutine as ,

    Private Sub ToolBar_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar.ButtonClick

        Dim objItemMaster As New ItemMaster

        Select Case e.Button.Tag
            Case "New"
                Call objItemMaster.Perform_ButtonClick("New")
            Case "Find"

            Case "Save"

            Case "Refresh"

            Case "Delete"

            Case "Print"

            Case "Close"
        End Select
    End Sub

   then it's working fine. but I have to create the object from the active form (form loaded on the MDI)



 
Old December 9th, 2005, 08:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Okay Okay, Plese verify the following
1) U have defined a Perform_ButtonClick sub in the child form class defination.
2) Your Child Form class's name is ItemMaster

If my understanding of your problem is right then yours is not a problem at all. You are just missing a step.
The thing is that ActiveMdiChild property is of type Form and Form class indeed doesnt have
any function named Perform_ButtonClick defined in it, as the error indicated in one of your previous
posts suggests.
What you need to do is to cast the ActiveMdiChild to ItemMaster, and then call Perform_ButtonClick,
something like

CType(parForm.ActiveMdiChild,ItemMaster).Perform_B uttonClick("New")

where parForm is your MDI parent.

Regards
Ankur Verma
 
Old December 12th, 2005, 11:35 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default

Hi Ankur,

   I tried what you told. but it highlights "MainMenu.ActiveMdiChild" part as a syntax error. MainMenu is my MDI form class name.

CType(MainMenu.ActiveMdiChild, ItemMaster).Perform_ButtonClick("New")

MainMenu - MDI form class name.
ItemMaster - Child form class name.

Can you please tell me a solution.

ThanX,

 
Old December 14th, 2005, 05:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Hi Nalla,
I lost touch with the forum for a while. Have you managed to figure out the solution?
If Not, then can you post the exact error you are getting at MainMenu.ActiveMdiChild line.
Because I dont see, why it wont work.
Also I dont know what the word 'Nalla' means. So please enlighten me on that.

Regards
Ankur
 
Old December 14th, 2005, 06:30 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default


Hi Ankur,

Ok. I'll post the source codes of MainMenu.vb and ItemMaster.vb,

MainMenu.vb

    Private Sub ToolBar_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar.ButtonClick

        'Dim objActiveForm As System.Windows.Forms.Form = ActiveForm.Name
        Dim objItemMaster As New ItemMaster

        'Dim objItemMaster As Form = Form.ActiveForm
        ActivateMdiChild(objItemMaster)

        Select Case e.Button.Tag
            Case "New"
                CType(MainMenu.ActiveMdiChild, ItemMaster).Perform_ButtonClick("New")
            Case "Find"

            Case "Save"

            Case "Refresh"

            Case "Delete"

            Case "Print"

            Case "Close"
        End Select
    End Sub


ItemMaster.vb

    Public Sub Perform_ButtonClick(ByVal Button As String)
        Select Case Button
            Case "New"

            Case "Find"

            Case "Save"

            Case "Refresh"

            Case "Delete"

            Case "Print"

            Case "Close"
        End Select
    End Sub

I think those 2 functions are enough for you to understand my problem. If I can have yout e-mail I'll mail you the project.



 
Old December 14th, 2005, 06:37 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default



Hi Ankur,

Sorry I forgot to mention about nalla. nalla means my nick name. My actual name is Nalaka Sanjeewa. My firends call me nalla. It doesn't mean anything, it's like we call "Arhar" to "Azharudin"









Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveForm in Mobile Web Form japie ASP.NET 1.0 and 1.1 Professional 0 November 2nd, 2005 02:39 AM





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