473,320 Members | 2,012 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,320 software developers and data experts.

C# -> two buttons same code

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();
}

Sep 6 '07 #1
3 1407
On Thu, 6 Sep 2007 15:34:12 -0400, "Al Biheiri" <ab******@gmail.com>
wrote:
>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.LinkLabelLinkClickedEventArg s e)
{
notifyIcon1.Visible = true; WindowState =
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 --------------------------------

private void mnuTray_Click(object sender,
System.Windows.Forms.LinkLabelLinkClickedEventArg s , System.EventArgs e)
{
notifyIcon1.Visible = true; WindowState =
FormWindowState.Minimized; Hide();
}
Sep 6 '07 #2
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"rossum" <ro******@coldmail.comwrote in message
news:6t********************************@4ax.com...
On Thu, 6 Sep 2007 15:34:12 -0400, "Al Biheiri" <ab******@gmail.com>
wrote:
>>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.LinkLabelLinkClickedEventAr gs e)
{
notifyIcon1.Visible = true; WindowState =
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 --------------------------------

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

Sep 6 '07 #3
yea that works...should of thought about that,,,, woops

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:O9**************@TK2MSFTNGP02.phx.gbl...
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"rossum" <ro******@coldmail.comwrote in message
news:6t********************************@4ax.com...
>On Thu, 6 Sep 2007 15:34:12 -0400, "Al Biheiri" <ab******@gmail.com>
wrote:
>>>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.LinkLabelLinkClickedEventA rgs e)
{
notifyIcon1.Visible = true; WindowState =
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 --------------------------------

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

Sep 6 '07 #4

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

Similar topics

4
by: Ricardo Santos | last post by:
Hi, I have a Python AST, which I have modified slightly (but still a valid Python AST). How do I go back to its source code representation? source code -> AST (POSSIBLE) AST -> source code ...
1
by: Keith R | last post by:
I have VB6, and eventually plan to upgrade to dotnet. I will soon start writing an application that will be mostly local (client?) but will interface with a server a few times, to authenticate...
3
by: Jon Rea | last post by:
is there a c# -> c++ code converter out there ? Hi people, I was just wondering if there is a C# to C++ converter out there. I have some working c# code and need to integrate it into a...
3
by: Henry Johnson | last post by:
Okay - I'm spinning my wheels on this one... can someone help me figure out how to programmatically populate a table cell as follows (from C# code-behind)? I've tried using a Literal control in the...
5
by: David Thielen | last post by:
Hi; Almost all of the Quick Starts show the code in the .aspx file inside a <script> instead of in a seperate .aspx.cs file. My instinct is that the code should be in a seperate file to keep the...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
13
by: Mich | last post by:
Hi, 1) i defined a html line in the aspx file like this but it's still visible:: <hr id="hr1" visible="false" /> So i defined it like this and now it's hidden: <hr id="hr1"...
1
by: Andreas Prilop | last post by:
I've come along a strange behaviour (bug?) in the Mozilla/Firefox browsers. It does not happen in Internet Explorer. When I have *disabled* the option "Allow pages to choose their own fonts" and...
1
by: jty0734 | last post by:
if you have mips cross compiler, please convert this c code to mips code. i'm try to install mips compiler 3 days, but some error fail to that. so if you have something cross compiler c code...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.