how to find button click event of one form into another form


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: how to find button click event of one form into another form

  1. #1
    Join Date
    Apr 2007
    Posts
    33

    how to find button click event of one form into another form

    Hi,
    I have one problem. I have one form, in that one text box and one button is there. And I have anothe form, in that i have status strip. when i click button in the first form i want message in the second form status strip.
    Plz help me on this

    Thanks.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Just reference the form name.the control name and you can pass the control on one form data from another form.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Apr 2007
    Posts
    33

    I tried it, but its not coming

    I tried it, but its not coming

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Post what you tried.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Apr 2007
    Posts
    33
    frmconfigcheckermain.toolstripstatueslabelmain

    frmConfigCheckerMain------this is form name
    toolstripstatueslabelmain--------this is contol name

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    As an example of passing data
    Code:
    'from Form1
    Form2.TextBox1.Text = "Hello World"
    You should be able to adapt this to your situation.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  7. #7
    Join Date
    Apr 2007
    Posts
    33

    Hi Hack

    Hi Hack,

    Like this I tried but I am not geeting the control name. And also I changed access specifier also to public, still i didn't get that one.

  8. #8
    Join Date
    Aug 2006
    Posts
    84
    This may work in VB.NET but not in C#.NET. That is bcz in VB.NET all controls's modifier is FRIEND. But in C#.NET all are private. So we cant directly access the other forms controls in C#.NET as we do in VB.NET.

  9. #9
    Join Date
    Apr 2007
    Posts
    33

    Hi Hack

    But in C# what can I do for this problem

  10. #10
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I didn't see where he was using C#.

    Are you Aazaad?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  11. #11
    Join Date
    Aug 2006
    Posts
    84
    Its just an estimation, if it is VB.NET he could have got it to work with your solution at the first message. But he did not. So I came to know that it is C#.NET.

  12. #12
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    In .NET, controls are declared as Friend (in VB) or private (in C#) by default. In order to use the method Hack suggests, you must go into the "Windows Forms Designer Generated Code" in the [Form Name].designer file and change the control declarations from Friend or private to public.

    A cleaner approach, in my opinion, is to create a public property in the form which modifies the desired control. In frmConfigCheckerMain, add this:
    Code:
    public string StatusLabel
    { 
        get
        {
            return toolstripStatusLabelMain.Text;
        }
        set
        {
            toolstripStatusLabelMain.Text = value;
        }
    }
    Then in your form with the textbox and the button, you may simply do this:
    Code:
    // ConfigCheckerInstance is a local instance of frmConfigCheckerMain
    ConfigCheckerInstance.StatusText = "Whatever";
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  13. #13
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Have a look at this link.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  14. #14
    Join Date
    Aug 2006
    Posts
    84
    Hi Weber... that was a nice approach and Very good link Hack, it explains different approaches.
    But in that we have to create an object to the other form. Is there any approach where we can pass the value with out creating the object to any of the forms, just like in VB.NET???

  15. #15
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    Quote Originally Posted by RoughGuy
    Is there any approach where we can pass the value with out creating the object to any of the forms, just like in VB.NET???
    Not that I found. This is not to say such an approach doesn't exist, but when I was goggling this subject, I found nothing that mimic's the way VB.NET handles this.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. Replies: 0
    Last Post: 05-26-2007, 03:14 PM
  2. Replies: 8
    Last Post: 05-23-2007, 01:31 PM
  3. Click Event of Listbox
    By jcb1269 in forum .NET
    Replies: 3
    Last Post: 10-25-2006, 04:08 PM
  4. Re: App Object (fixes)
    By Rob Teixeira in forum .NET
    Replies: 129
    Last Post: 06-06-2002, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center