Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

C# -> two buttons same code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Al Biheiri - 06 Sep 2007 20:34 GMT
i forgot how to do this someone help

how do i make this into one

       private void mnuTray_Click(object sender, System.EventArgs e)
       {
           notifyIcon1.Visible = true; WindowState =
FormWindowState.Minimized; Hide();
       }

       private void lnkTray_LinkClicked(object sender,
System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
       {
           notifyIcon1.Visible = true; WindowState =
FormWindowState.Minimized; Hide();
       }

I remember I had to change it to something
like --------------------------------

       private void mnuTray_Click(object sender,
System.Windows.Forms.LinkLabelLinkClickedEventArgs , System.EventArgs e)
       {
           notifyIcon1.Visible = true; WindowState =
FormWindowState.Minimized; Hide();
       }
rossum - 06 Sep 2007 20:59 GMT
>i forgot how to do this someone help
>
[quoted text clipped - 12 lines]
>FormWindowState.Minimized; Hide();
>        }
Have you tried:

  private void lnkTray_LinkClicked(object sender,
        System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
  {
      mnuTray_Click(sender, e);
  }

to call the first button click action when the second button is
clicked?

rossum

>I remember I had to change it to something
>like --------------------------------
[quoted text clipped - 5 lines]
>FormWindowState.Minimized; Hide();
>        }
Nicholas Paldino [.NET/C# MVP] - 06 Sep 2007 21:05 GMT
The neater way would be to refactor this into a single method, like so:

private void LinkClickedEventHandler()
{
   notifyIcon1.Visible = true;
   WindowState = FormWindowStateMinimized;
   Hide();
}

   And then call that from each event handler.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>>i forgot how to do this someone help
>>
[quoted text clipped - 34 lines]
>>FormWindowState.Minimized; Hide();
>>        }
Al Biheiri - 06 Sep 2007 21:11 GMT
yea that works...should of thought about that,,,, woops

>    The neater way would be to refactor this into a single method, like so:
>
[quoted text clipped - 45 lines]
>>>FormWindowState.Minimized; Hide();
>>>        }
zacks@construction-imaging.com - 06 Sep 2007 21:01 GMT
> i forgot how to do this someone help
>
[quoted text clipped - 22 lines]
> FormWindowState.Minimized; Hide();
>         }

Typo in my last. Should be:

In the mnuTray_Click event handler, substitute the following code for
what is there:

InkTray.PerformClick();

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.