How to pass more than two parameters in the event handler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Duniho

    #16
    Re: How to pass more than two parameters in the event handler

    On Fri, 18 Jul 2008 02:23:02 -0700, Ciaran O''Donnell
    <CiaranODonnell @discussions.mi crosoft.comwrot e:
    Sorry about the mistake Peter. I'll add it to the list of many times I
    should
    have read the small print to avoid an embarassing or costly mistake.
    No problem at all. It was an honest mistake, and so I wouldn't call it
    embarassing, nor did it seem costly (well, not to me or you, anyway :) ).

    Comment

    • Peter Duniho

      #17
      Re: How to pass more than two parameters in the event handler

      On Fri, 18 Jul 2008 09:41:17 -0700, raylopez99 <raylopez99@yah oo.com>
      wrote:
      On Jul 18, 9:27 am, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
      wrote:
      >
      >I'm happy to ignore those attacks; after all, they say a lot more about 
      >you than they do about me.  But a person deserving of community respect
      >knows when they've crossed the line and _sincerely_ apologizes for it.
      >
      OK, OKAY. Jeez I didn't realise you such a shrinking violet.
      I'm not. You fail to get the point.
      "I sincerely appologize" for flaming you. happy now?
      I was happy before. Your quoted statement doesn't change that one way or
      the other (nor does it seem sincere to me).

      Until you fully comprehend what I actually wrote, I don't believe it will
      be possible for you to offer a sincere apology. And it's clear you don't
      comprehend what I wrote.

      Pete

      Comment

      • raylopez99

        #18
        Re: How to pass more than two parameters in the event handler

        On Jul 18, 9:59 am, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
        wrote:
        >
        Until you fully comprehend what I actually wrote, I don't believe it will 
        be possible for you to offer a sincere apology.  And it's clear you don't  
        comprehend what I wrote.
        >
        I'm REALLY sorry, OK? Besides I need guys like you to help me learn
        C# and debug my code when I run into a brick wall, so I have to be
        nice--self interest you know. So far though, I'm not having too many
        problems with C# Forms, which seem to be more robust than the GUI
        database stuff for C# (the frequent casting there seems terrible and
        undocumented, and stuff is always not compiling even when copied from
        a book).

        RL

        Comment

        • dondigitech LaPel

          #19
          Re: How to pass more than two parameters in the event handler

          I am also having a similar problem.I would like to pass in an extra
          parameter in my event handler being that I need the information
          (curveArray = 2d array where each array has 64 values) to plot graphs on
          the user interface. So heress the low down, I have a class called
          CurveData that does calculations on data read from a unit via serial
          port and returns a 2D array (curveArray) in the method called
          initializeIgnCo mm. That information is passed into the event handler
          getCurvesToolSt ripMenuItem_Cli ck1, sorted to a list, and that list is
          used in plotCurves to generate a plot. I don’t know if this is the best
          way to go about this but I am unable to think of a way to get this
          curveArray data without passing parameters in. So here is the event
          handler code in my main form file as well as methods called in the event
          handler:

          //EVENT HANDLER
          private void getCurvesToolSt ripMenuItem_Cli ck1(object sender, int[,]
          curveArray)
          {
          comm.DisplayWin dow = rtbDisplay;
          try
          {
          if (serialPort1.Is Open)
          {
          comm.initialize IgnComm(serialP ort1);
          plotCurves(zedG raphControl1, curveArray);
          }
          else
          {
          MessageBox.Show ("Error: COM port closed.");
          return; // bail out
          }
          }
          catch (System.Excepti on ex)
          {
          MessageBox.Show ("Error - findIgnButton_C lick Exception:
          " + ex);
          }

          }
          #endregion

          private void plotCurves(ZedG raphControl zgc, int[,] curveArray)
          {
          GraphPane plotCurve = zgc.GraphPane; //Get a
          reference to the GraphPane

          // Set the Titles
          plotCurve.Title .Text = "DFS726 IGNITION TIMING\n";
          plotCurve.XAxis .Title.Text = "RPM(x100)" ;
          plotCurve.YAxis .Title.Text = "Advance Angle(Degrees BTDC)";

          PointPairList curve1 = new PointPairList() ; //Create
          curve1 list
          sortData(curveA rray); //Sort data into
          list for plotting

          LineItem ignCurve = plotCurve.AddCu rve("WOT Curve 4",
          curve1, Color.Red, SymbolType.Diam ond);
          zgc.AxisChange( );

          }
          #endregion

          private PointPairList sortData(int[,] curveArray)
          {
          int numberOfCurves = 8;
          int[,] advDegBTDC = new int[numberOfCurves, 8];
          int[,] rpmValues = new int[numberOfCurves, 8];
          int curveNumber = 0;
          int arrayIndex = 0;
          int genArrayIndex = 0;

          // Copy data from rpmArray and advArray into rpmValues and
          advDegBTDC arrays used for plots
          for (curveNumber = 0; curveNumber < numberOfCurves;
          curveNumber++)
          {
          for (arrayIndex = 0; arrayIndex < 8; arrayIndex++)
          {
          advDegBTDC[curveNumber,arr ayIndex] =
          curveArray[0,genArrayIndex];
          rpmValues[curveNumber,arr ayIndex] =
          curveArray[1,genArrayIndex];
          genArrayIndex++ ;
          }
          }
          PointPairList list1 = new PointPairList() ;

          // TEST: Just sending the first curve (8 data points) to
          list1 to graph
          for (int i = 0; i < 8; i++)
          {
          list1.Add(rpmVa lues[0,i], advDegBTDC[0,i]);
          }
          return list1;

          }


          I’ve only been using C# for a couple weeks so forgive me if my coding is
          not up to proper standards. Thanks in advance!




          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          • Jeff Johnson

            #20
            Re: How to pass more than two parameters in the event handler

            "dondigitec h LaPel" <dlapel@dynaonl ine.comwrote in message
            news:uEnIgVgOJH A.3876@TK2MSFTN GP04.phx.gbl...
            >I am also having a similar problem.I would like to pass in an extra
            parameter in my event handler
            I don't see the post that you replied to, so I'm making assumptions about
            the original question.

            My first assumption is that you're defining your OWN event handler and not
            dealing with an event model that is out of your control. The .NET standard
            is to pass only two parameters in an event handler: an instance of Object
            that represents the object which raised the event (the sender) and an
            instance of EventArgs--or a class derived from EventArgs--which contains all
            the necessary information that a subscriber (consumer) might need. The part
            about derived classes is important. If you need to provide information to
            your event consumers then you should derive a class from EventArgs and add
            properties to that class to hold that necessary data. (Well, unless the
            Framework already provides a derived class which gives you exactly what you
            need.)

            Most of the time these properties are for one-way information: from the
            sender to the consumer, but sometimes the consumer will pass information
            back to the sender (an event which can be canceled is a perfect example of
            this).


            Comment

            • =?Utf-8?B?ZG9uZGlnaXRlY2g=?=

              #21
              Re: How to pass more than two parameters in the event handler

              I still can't seem to get this to work. I created the event but was unable to
              get anything to happen when I clicked on the button. This was the code in the
              designer form file:

              this.click += new
              getCurveButtonH andler(this.get CurvesToolStrip MenuItem_Click) ;

              So I've done the following in my main form file:

              // Create EventArgs subclass to pass in 2D array parameter
              public class EventArgs_2Darr ay : EventArgs
              {
              public int[,] curveArray;
              public EventArgs_2Darr ay(int[,] array)
              {
              curveArray = array;
              }
              }
              // Delegate declaration
              public delegate void getCurveButtonH andler(object sender, int[,]
              array);
              public event getCurveButtonH andler click;

              My event handler is:

              private void getCurvesToolSt ripMenuItem_Cli ck(object sender,
              EventArgs_2Darr ay )
              {
              comm.DisplayWin dow = rtbDisplay;
              try
              {
              if (serialPort1.Is Open)
              {
              comm.initialize IgnComm(serialP ort1);
              plotCurves(zedG raphControl1, curveArray);
              }
              else
              {
              MessageBox.Show ("Error: COM port closed.");
              return; // bail out
              }
              }
              catch (System.Excepti on ex)
              {
              MessageBox.Show ("Error - findIgnButton_C lick Exception: " +
              ex);
              }

              }

              I still am not seeing how I can pass int[,] curveArray in as a parameter
              because obviously I'm getting "The name 'curveArray' does not exist in the
              current context" error. And in my designer form the click event is created as
              such:

              this.getCurvesT oolStripMenuIte m.Click += new
              getCurveButtonH andler(this.get CurvesToolStrip MenuItem_Click) ;

              The event Click built into the ToolStripMenuIt em is handled by the
              EventHandler which only passes in the 2 parameters (object sender, EventArgs
              e). So, of course I get the "Error1 No overload for
              'getCurvesToolS tripMenuItem_Cl ick' matches delegate
              'PCComm.frmMain .getCurveButton Handler' error. Since the ToolStripMenuIt em
              class is being used to initialize all the items on the menu strip i've used
              (I have 3 which include the getCurvesToolSt ripMenuItem) is there a way to
              just make this single item work passing in the 2D array parameter. I've tried
              copying the entire ToolStripMenuIt em class and adding another event that uses
              my event handler getCurveButtonH andler but seems like this is not the best
              solution. Need help!

              "Jeff Johnson" wrote:
              "dondigitec h LaPel" <dlapel@dynaonl ine.comwrote in message
              news:uEnIgVgOJH A.3876@TK2MSFTN GP04.phx.gbl...
              >
              I am also having a similar problem.I would like to pass in an extra
              parameter in my event handler
              >
              I don't see the post that you replied to, so I'm making assumptions about
              the original question.
              >
              My first assumption is that you're defining your OWN event handler and not
              dealing with an event model that is out of your control. The .NET standard
              is to pass only two parameters in an event handler: an instance of Object
              that represents the object which raised the event (the sender) and an
              instance of EventArgs--or a class derived from EventArgs--which contains all
              the necessary information that a subscriber (consumer) might need. The part
              about derived classes is important. If you need to provide information to
              your event consumers then you should derive a class from EventArgs and add
              properties to that class to hold that necessary data. (Well, unless the
              Framework already provides a derived class which gives you exactly what you
              need.)
              >
              Most of the time these properties are for one-way information: from the
              sender to the consumer, but sometimes the consumer will pass information
              back to the sender (an event which can be canceled is a perfect example of
              this).
              >
              >
              >

              Comment

              • Peter Duniho

                #22
                Re: How to pass more than two parameters in the event handler

                On Thu, 30 Oct 2008 14:02:01 -0700, dondigitech
                <dondigitech@di scussions.micro soft.comwrote:
                // Create EventArgs subclass to pass in 2D array parameter
                public class EventArgs_2Darr ay : EventArgs
                {
                [...]
                }
                // Delegate declaration
                public delegate void getCurveButtonH andler(object sender, int[,]
                array);
                public event getCurveButtonH andler click;
                >
                My event handler is:
                >
                private void getCurvesToolSt ripMenuItem_Cli ck(object sender,
                EventArgs_2Darr ay )
                It would really help if you'd post the _actual_ code, copied and pasted.
                Since your method declaration is missing the actual argument name for the
                second argument, the above obviously isn't from a real program, which
                makes it hard to provide a real answer.

                That said...

                Your delegate type needs to match the event handler itself. Your event
                handler method takes as the second argument an instance of
                EventArgs_2Darr ay, but your delegate type takes as the second argument a
                two-dimensional "int[,]" array.

                The most obvious fix is to change the argument type in the delegate type
                from "int[,]" to "EventArgs_2Dar ray".

                Note that an alternative to declaring the delegate type would be to just
                use the generic EventHandler<Tt ype:

                public event EventHandler<Ev entArgs_2Darray click;

                Now, there are other issues with the code that you've posted, not the
                least of which is that the "Click" event is already a well-defined .NET
                Control-class event that uses the EventHandler delegate type, and
                redefining that for your own purpose is probably a big mistake. Other
                issues are less significant, such as the use of a public field instead of
                a property in the EventArgs sub-class, while other issues may be even more
                significant, such as the question of what it is exactly you really want
                this event handler to do and how you expect it to do it (so far, you've
                been relatively vague on those specifics, making it difficult to provide a
                good answer).

                But at the very least, hopefully the above should help you move closer to
                code that compiles. Once we get there, it'll probably be easier to answer
                the really interesting parts of the question. :)

                Pete

                Comment

                • =?Utf-8?B?ZG9uZGlnaXRlY2g=?=

                  #23
                  Re: How to pass more than two parameters in the event handler

                  I did have both the delegate and event handler passing in the same params but
                  I changed it to see what would happen. Basically I have a class called
                  CurveData which reads data and calculates values and returns a 2D array which
                  I am trying to pass into the sortData and plotCurves methods in the main
                  form. A list is supposed to be generated which is then used in the plotCurves
                  method to display a graph. This is frustrating becuase it seems like i'm
                  close to getting this done but am having problems attacking this situation of
                  getting information from curveArray into this main form file. I hope this
                  clarifies my objective and the problems that I'm having. If you have any
                  advice for a different approach, it'd be much appreciated. Anywho, here is
                  the code from my main form file:

                  using System;
                  using System.Collecti ons.Generic;
                  using System.Componen tModel;
                  using System.Data;
                  using System.Drawing;
                  using System.Text;
                  using System.IO.Ports ;
                  using System.Windows. Forms;
                  using System.Threadin g;
                  using PCComm;
                  using PortSet;
                  using ZedGraph;

                  namespace PCComm
                  {
                  public partial class frmMain : Form
                  {
                  CurveData comm = new CurveData();
                  string transType = string.Empty;

                  // Create EventArgs subclass to pass in 2D array parameter
                  public class EventArgs_2Darr ay : EventArgs
                  {
                  public int[,] target;
                  public EventArgs_2Darr ay(int[,] array)
                  {
                  target = array;
                  }
                  }
                  // Delegate declaration
                  public delegate void getCurveButtonH andler(object sender,
                  EventArgs_2Darr ay e);
                  public event getCurveButtonH andler click;
                  public getCurveButtonH andler clickSubscriber s
                  {
                  get { return click; }
                  }

                  public frmMain()
                  {
                  InitializeCompo nent();
                  }

                  private void frmMain_Load(ob ject sender, EventArgs e)
                  {
                  //LoadValues();
                  //SetDefaults();
                  }

                  private void LoadValues()
                  {
                  }


                  //=============== =============== =============== =============== =============== ============
                  # region MENU STRIP CONTROL
                  /// <summary>
                  /// Menu strip which controls serial port settings, opening and
                  closing the serial
                  /// port, acquiring ignition timing data as well as plotting out the
                  advance curves.
                  /// These functions below are executed in the event the user clicks
                  on a button on the
                  /// menu strip at the top of the form.
                  /// </summary>
                  //
                  //--------------------------------------------------------------------
                  //<<<<<<<<< SERIAL PORT SETTINGS MENU >>>>>>>>>>//
                  //--------------------------------------------------------------------
                  // Com port & baud rate settings can be changed by opening this menu.
                  //--------------------------------------------------------------------
                  private void settingsToolStr ipMenuItem_Clic k1(object sender,
                  EventArgs e)
                  {
                  // Make sure the port isn't already open
                  if (serialPort1.Is Open)
                  {
                  MessageBox.Show ("The port must be closed before changing the
                  settings.");
                  return;
                  }
                  else
                  {
                  // Create an instance of the settings form
                  PortSettings settings = new PortSettings();
                  if (settings.ShowD ialog() == DialogResult.OK )
                  {
                  if (settings.selec tedPort != "")
                  {
                  // Set the serial port to the new settings
                  serialPort1.Por tName = settings.select edPort;
                  serialPort1.Bau dRate = settings.select edBaudrate;
                  showSettings();
                  }
                  else
                  {
                  MessageBox.Show ("Error: Settings form returned with
                  no COM port selected.");
                  return; // bail out
                  }
                  }
                  else
                  {
                  MessageBox.Show ("Error: buttonSetup_Cli ck - Settings
                  dialog box did not return Okay.");
                  return; // bail out
                  }
                  // Open the port
                  try
                  {
                  serialPort1.Clo se();
                  serialPort1.Ope n();
                  menuStrip1.Item s[1].Text = "Close Port";
                  showSettings();
                  }
                  catch (System.Excepti on ex)
                  {
                  MessageBox.Show ("Error - setupToolStripM enuItem_Click
                  Exception: " + ex);
                  }
                  }
                  }

                  //--------------------------------------------------------------------
                  //<<<<<<<<< OPEN/CLOSE PORT BUTTON >>>>>>>>>>//
                  //--------------------------------------------------------------------
                  // You can open or close the communication port by clicking this
                  button.
                  // Default settings are acquired if you have not changed them before
                  // clicking this button.
                  //--------------------------------------------------------------------
                  private void openPortToolStr ipMenuItem_Clic k(object sender,
                  EventArgs e)
                  {
                  try
                  {
                  if (serialPort1.Is Open)
                  {
                  serialPort1.Clo se();
                  menuStrip1.Item s[1].Text = "Open Port";
                  }
                  else
                  {
                  serialPort1.Ope n();
                  menuStrip1.Item s[1].Text = "Close Port";
                  }

                  showSettings();
                  }
                  catch (System.Excepti on ex)
                  {
                  MessageBox.Show ("Error - openPortToolStr ipMenuItem_Clic k
                  Exception: " + ex);
                  }
                  }

                  private void GroupBox1_Enter (object sender, EventArgs e)
                  {

                  }

                  //--------------------------------------------------------------------
                  //<<<<<<<<< GET CURVES BUTTON >>>>>>>>>>//
                  //--------------------------------------------------------------------
                  // Once communication is established with the ignition unit. You
                  // are able to download ignition data by clicking on "Get Curves"
                  button.
                  // The ignition data downloaded from EEPROM is sorted and
                  // the advances are calculated and then plotted on the graph provided.
                  //--------------------------------------------------------------------
                  private void getCurvesToolSt ripMenuItem_Cli ck(object sender,
                  EventArgs_2Darr ay e)
                  {
                  comm.DisplayWin dow = rtbDisplay;
                  try
                  {
                  if (serialPort1.Is Open)
                  {
                  comm.initialize IgnComm(serialP ort1);
                  plotCurves(zedG raphControl1);
                  }
                  else
                  {
                  MessageBox.Show ("Error: COM port closed.");
                  return; // bail out
                  }
                  }
                  catch (System.Excepti on ex)
                  {
                  MessageBox.Show ("Error - findIgnButton_C lick Exception: " +
                  ex);
                  }

                  }
                  #endregion


                  //=============== =============== =============== ===
                  # region CURVE ID HEADER
                  /// <summary>
                  /// The header on the Curve Identifier application displays serial
                  port status,
                  /// serial port name and baud rate.
                  /// </summary>
                  //=============== =============== =============== ===
                  private void showSettings()
                  {
                  this.Text = "DYNATEK IGNITIONS - " +
                  serialPort1.Por tName + " " +
                  serialPort1.Bau dRate.ToString( );
                  if (serialPort1.Is Open)
                  {
                  this.Text += " - Port is open";
                  }
                  else
                  {
                  this.Text += " - Port is closed";
                  }
                  }
                  #endregion


                  //=============== =============== =============== ===
                  # region GRAPH CURVES
                  /// <summary>
                  /// This function controls the graphing of the ignition advance
                  curves.
                  /// </summary>
                  //=============== =============== =============== ===
                  private void zedGraphControl 1_Load(object sender, EventArgs e)
                  {
                  }

                  private void plotCurves(ZedG raphControl zgc)
                  {
                  GraphPane plotCurve = zgc.GraphPane; //Get a
                  reference to the GraphPane

                  int[,] curvePointsArra y;
                  curvePointsArra y = comm.GetData();

                  // Set the Titles
                  plotCurve.Title .Text = "DFS726 IGNITION TIMING\n";
                  plotCurve.XAxis .Title.Text = "RPM(x100)" ;
                  plotCurve.YAxis .Title.Text = "Advance Angle(Degrees BTDC)";

                  PointPairList curve1 = new PointPairList() ; //Create curve1
                  list
                  sortData(curveP ointsArray); //Sort data into
                  list for plotting

                  LineItem ignCurve = plotCurve.AddCu rve("WOT Curve 4", curve1,
                  Color.Red, SymbolType.Diam ond);
                  zgc.AxisChange( );

                  }
                  #endregion

                  //--------------------------------------------------
                  // SORT ARRAY DATA TO POINTS FUNCTION
                  //--------------------------------------------------
                  private PointPairList sortData(int[,] curveArray)
                  {
                  int numberOfCurves = 8;
                  int[,] advDegBTDC = new int[numberOfCurves, 8];
                  int[,] rpmValues = new int[numberOfCurves, 8];
                  int curveNumber = 0;
                  int arrayIndex = 0;
                  int genArrayIndex = 0;

                  // Create array of arrays to store rpm and advance degree values
                  for ignition curves
                  //for (int q = 0; q < numberOfCurves; q++)
                  //{
                  // advDegBTDC[q,] = new int[8];
                  // rpmValues[q,] = new int[8];
                  //}

                  // Copy data from rpmArray and advArray into rpmValues and
                  advDegBTDC arrays used for plots
                  for (curveNumber = 0; curveNumber < numberOfCurves; curveNumber++)
                  {
                  for (arrayIndex = 0; arrayIndex < 8; arrayIndex++)
                  {
                  advDegBTDC[curveNumber,arr ayIndex] =
                  curveArray[0,genArrayIndex];
                  rpmValues[curveNumber,arr ayIndex] =
                  curveArray[1,genArrayIndex];
                  genArrayIndex++ ;
                  }
                  }
                  PointPairList list1 = new PointPairList() ;

                  // TEST: Just sending the first curve (8 data points) to list1
                  to graph
                  for (int i = 0; i < 8; i++)
                  {
                  list1.Add(rpmVa lues[0,i], advDegBTDC[0,i]);
                  }
                  return list1;

                  }
                  }
                  }

                  And here is the section code from the form designer file that applies to
                  this instance:

                  //
                  // getCurvesToolSt ripMenuItem
                  //
                  this.getCurvesT oolStripMenuIte m.Name =
                  "getCurvesToolS tripMenuItem";
                  this.getCurvesT oolStripMenuIte m.Size = new
                  System.Drawing. Size(73, 20);
                  this.getCurvesT oolStripMenuIte m.Text = "Get Curves";
                  this.getCurvesT oolStripMenuIte m.Click += new
                  System.EventHan dler(this.getCu rvesToolStripMe nuItem_Click);

                  "Peter Duniho" wrote:
                  On Thu, 30 Oct 2008 14:02:01 -0700, dondigitech
                  <dondigitech@di scussions.micro soft.comwrote:
                  >
                  // Create EventArgs subclass to pass in 2D array parameter
                  public class EventArgs_2Darr ay : EventArgs
                  {
                  [...]
                  }
                  // Delegate declaration
                  public delegate void getCurveButtonH andler(object sender, int[,]
                  array);
                  public event getCurveButtonH andler click;

                  My event handler is:

                  private void getCurvesToolSt ripMenuItem_Cli ck(object sender,
                  EventArgs_2Darr ay )
                  >
                  It would really help if you'd post the _actual_ code, copied and pasted.
                  Since your method declaration is missing the actual argument name for the
                  second argument, the above obviously isn't from a real program, which
                  makes it hard to provide a real answer.
                  >
                  That said...
                  >
                  Your delegate type needs to match the event handler itself. Your event
                  handler method takes as the second argument an instance of
                  EventArgs_2Darr ay, but your delegate type takes as the second argument a
                  two-dimensional "int[,]" array.
                  >
                  The most obvious fix is to change the argument type in the delegate type
                  from "int[,]" to "EventArgs_2Dar ray".
                  >
                  Note that an alternative to declaring the delegate type would be to just
                  use the generic EventHandler<Tt ype:
                  >
                  public event EventHandler<Ev entArgs_2Darray click;
                  >
                  Now, there are other issues with the code that you've posted, not the
                  least of which is that the "Click" event is already a well-defined .NET
                  Control-class event that uses the EventHandler delegate type, and
                  redefining that for your own purpose is probably a big mistake. Other
                  issues are less significant, such as the use of a public field instead of
                  a property in the EventArgs sub-class, while other issues may be even more
                  significant, such as the question of what it is exactly you really want
                  this event handler to do and how you expect it to do it (so far, you've
                  been relatively vague on those specifics, making it difficult to provide a
                  good answer).
                  >
                  But at the very least, hopefully the above should help you move closer to
                  code that compiles. Once we get there, it'll probably be easier to answer
                  the really interesting parts of the question. :)
                  >
                  Pete
                  >

                  Comment

                  • Peter Duniho

                    #24
                    Re: How to pass more than two parameters in the event handler

                    On Fri, 31 Oct 2008 09:42:01 -0700, dondigitech
                    <dondigitech@di scussions.micro soft.comwrote:
                    Formatting got all messed up again! I wasted my time copying into
                    notepad and
                    spacing it out!!
                    I really don't know what you mean. Here, the code looks reasonably fine.
                    Maybe the Microsoft Communities web site just isn't showing it correctly.

                    The problem isn't in the formatting, it's in the content.

                    See:


                    Comment

                    • Jeff Johnson

                      #25
                      Re: How to pass more than two parameters in the event handler

                      "dondigitec h" <dondigitech@di scussions.micro soft.comwrote in message
                      news:0969D27D-2903-4672-974A-8E560A97CF20@mi crosoft.com...
                      Ultimately the issue I am having is getting/passing the curveArray data to
                      the event handler.
                      Okay, this is where you lose me. I haven't looked too deeply into the code
                      because, quite frankly, there's way too much of it and I'm just not going to
                      take the time. I'm assuming that you've got a form, because you talked about
                      clicking a button. Now you want to pass something to the event handler.
                      Guess what: YOU CAN'T. The event handler is being called by the button, and
                      you don't have access to the button's internal code to control the way it
                      raises events and the data it passes. (I'm not even going to go into the
                      subject of inheriting from the button....)

                      So instead of going down the path of trying to get the desired data PASSED
                      IN to the event handler, you should instead be looking for a way to RETRIEVE
                      it once you're in the handler. It's your code; why wouldn't you have access
                      to the array you're looking for?


                      Comment

                      Working...