Click here to Skip to main content
15,894,328 members
Home / Discussions / C#
   

C#

 
GeneralRe: full screen maximize Pin
Blue_Aqua5-Feb-04 17:27
Blue_Aqua5-Feb-04 17:27 
GeneralPointers to Interfaces for COM Pin
Tristan Rhodes5-Feb-04 2:24
Tristan Rhodes5-Feb-04 2:24 
GeneralProblem 2 Pin
Tristan Rhodes5-Feb-04 2:32
Tristan Rhodes5-Feb-04 2:32 
GeneralRe: Problem 2 Pin
Heath Stewart5-Feb-04 5:14
protectorHeath Stewart5-Feb-04 5:14 
GeneralRe: Problem 2 Pin
Tristan Rhodes5-Feb-04 5:33
Tristan Rhodes5-Feb-04 5:33 
GeneralRe: Problem 2 Pin
Heath Stewart5-Feb-04 6:53
protectorHeath Stewart5-Feb-04 6:53 
GeneralRe: Problem 2 Pin
Tristan Rhodes5-Feb-04 7:13
Tristan Rhodes5-Feb-04 7:13 
GeneralInt / UInt in flag issue Pin
Tristan Rhodes5-Feb-04 1:54
Tristan Rhodes5-Feb-04 1:54 
GeneralRe: Int / UInt in flag issue Pin
Colin Angus Mackay5-Feb-04 1:56
Colin Angus Mackay5-Feb-04 1:56 
GeneralRe: Int / UInt in flag issue Pin
Tristan Rhodes5-Feb-04 2:20
Tristan Rhodes5-Feb-04 2:20 
GeneralRe: Int / UInt in flag issue Pin
Heath Stewart5-Feb-04 5:05
protectorHeath Stewart5-Feb-04 5:05 
GeneralProblem with class inheritance Pin
Andres Coder5-Feb-04 1:34
Andres Coder5-Feb-04 1:34 
GeneralRe: Problem with class inheritance Pin
Corinna John5-Feb-04 1:50
Corinna John5-Feb-04 1:50 
GeneralRe: Problem with class inheritance Pin
Colin Angus Mackay5-Feb-04 1:55
Colin Angus Mackay5-Feb-04 1:55 
GeneralCOM interop reference problem Pin
vladll4-Feb-04 23:33
vladll4-Feb-04 23:33 
GeneralRe: COM interop reference problem Pin
Heath Stewart5-Feb-04 4:52
protectorHeath Stewart5-Feb-04 4:52 
GeneralRe: COM interop reference problem Pin
vladll5-Feb-04 5:38
vladll5-Feb-04 5:38 
GeneralRe: COM interop reference problem Pin
Heath Stewart5-Feb-04 6:58
protectorHeath Stewart5-Feb-04 6:58 
GeneralRe: COM interop reference problem Pin
vladll5-Feb-04 7:06
vladll5-Feb-04 7:06 
GeneralRe: COM interop reference problem Pin
Heath Stewart5-Feb-04 8:58
protectorHeath Stewart5-Feb-04 8:58 
GeneralSelecting buttons Pin
Megastoffel4-Feb-04 23:30
Megastoffel4-Feb-04 23:30 
GeneralRe: Selecting buttons Pin
Member 2611885-Feb-04 0:11
Member 2611885-Feb-04 0:11 
What about using two global variables (or an array, even better), and a counter. Then, when one button is clicked, the reference to the instance is saved in the first position, and when another button is clicked, it is saved in the second. Like this:
public class MyClass
{
  // Initialize a new array with a length of two (thus index 0 and 1):
  private Button[] _buttons = new Button[2];
  private int _counter = 0;
  
  // Handle the events of your buttons.
  public MyClass()
  {
    MyButton1.Click += new EventHandler(Button_Click);
    MyButton2.Click += new EventHandler(Button_Click);
    MyButton3.Click += new EventHandler(Button_Click);
    // Etc...
  }
  
  private void Button_Click(object sender, EventArgs e)
  {
    // Assign your button to the array,
    _buttons[_counter] = (Button)sender;
    // and increase the counter by 1.
    _counter++;
  }
}


Instead of manually assigning the events to your buttons in the class' constructor, you may want to use the Form-designer to do that. Just copy-and-paste the name of the method that handles the event in the field next to 'Click' on the 'Events' tab of the propertygrid of your buttons.

Don't forget to reset the counter (_counter = 0) when you're finished, or add a check to see whether _counter > _buttons.Length - 1, then:
if (_counter > _buttons.Length - 1) _counter = 0;

GeneralRe: Selecting buttons Pin
Megastoffel5-Feb-04 7:38
Megastoffel5-Feb-04 7:38 
GeneralPrintPreviewDialog Pin
Reinier van de Wetering4-Feb-04 22:25
Reinier van de Wetering4-Feb-04 22:25 
Generalconversion to pdf Pin
mohdshiraz4-Feb-04 19:11
mohdshiraz4-Feb-04 19:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.