none
delegate ?? RRS feed

  • Question

  • using delegate ... i wanna  create an panel and inside the panel i wanna create checkbox when i click the button on the form... but panel and checkbox should create at "runtime"... 

    after that when i check the checkbox... it should display a messagebox...

    please help me with ur code...

    Friday, March 4, 2011 6:51 AM

Answers

  • Kabilan,

    I'm not sure what you're trying to do, but I think you would do something like this:

    1) Define your delegate function:

       delegate void createPanel();

    createPanel cp = new createPanel(onCreatePanel);

    bool onCreatePanel()

    {

    // Create the panel with the checkbox

    Panel pnl = new System.Windows.Forms.Panel();

    //set the location of the panel;

    CheckBox cbx = new System.Windows.Forms.CheckBox();

    pnl.Controls.Add(cbx);

    // add an event handler for the clicking on the checkbox

    // Show the panel

    }

    You would call the function by:

    Invoke(cp);

    This isn't complete and I've just typed it in so it won't compile but it should point you in the right direction.

    Charles

     


    Useful Software, Inc. Celebrating 25 years of software solutions.
    Friday, March 4, 2011 7:42 AM

All replies

  • Kabilan,

    I'm not sure what you're trying to do, but I think you would do something like this:

    1) Define your delegate function:

       delegate void createPanel();

    createPanel cp = new createPanel(onCreatePanel);

    bool onCreatePanel()

    {

    // Create the panel with the checkbox

    Panel pnl = new System.Windows.Forms.Panel();

    //set the location of the panel;

    CheckBox cbx = new System.Windows.Forms.CheckBox();

    pnl.Controls.Add(cbx);

    // add an event handler for the clicking on the checkbox

    // Show the panel

    }

    You would call the function by:

    Invoke(cp);

    This isn't complete and I've just typed it in so it won't compile but it should point you in the right direction.

    Charles

     


    Useful Software, Inc. Celebrating 25 years of software solutions.
    Friday, March 4, 2011 7:42 AM
  • Can you explain why you need a delegate. You can just create the panel in Click event of the button.
    Tan Silliksaar milemarx.com
    Friday, March 4, 2011 7:45 AM