Adding into listbox

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

    Adding into listbox

    i have created one windows application form (form1) in vc# . there is one
    listbox in that form. i have anothere form( form2). From form2 i have give
    one button. on the click event of that button i have to load items from the
    listbox which is in form1. how can i do this? plz give solution for this

    thanking u

  • Josema

    #2
    RE: Adding into listbox

    Hi Lkr,

    You can create in the form 2 class a event and a method to handle the event
    like this:

    public event EventHandler form2buttonclic k;

    public virtual void OnForm2ButtonCl ick(object sender, EventArgs e)
    {
    if(form2buttonc lick!=null)
    {
    form2buttonclic k(sender,e);
    }
    }

    Then add this piece of code in the onclick button in the form2

    OnForm2ButtonCl ick(sender, e);


    And once you have this, go to the form1, in the OnInit method you have to
    have something like this:
    Form form2=new form2();

    add this line:
    form2.OnForm2Bu ttonClick +=new EventHandler(Fo rm2ButtonClick)

    private void Form2ButtonClic k(object sender, EventArgs e)
    {
    MessageBox.Show ("The user Clicks in the button of the Form2");
    }

    Hope this helps.
    Kind Regards.
    Josema.
    "lkr" wrote:
    [color=blue]
    > i have created one windows application form (form1) in vc# . there is one
    > listbox in that form. i have anothere form( form2). From form2 i have give
    > one button. on the click event of that button i have to load items from the
    > listbox which is in form1. how can i do this? plz give solution for this
    >
    > thanking u
    >[/color]

    Comment

    • lkr

      #3
      RE: Adding into listbox

      hi
      my question is i created a windows form in c# ie Form1in that form1i
      created a listbox.and also created another form Form2. i have a link in form1
      to form2. in form2 i created a button. on the click event of the button i am
      compiling one java code and i want tht compilation output to be loaded into
      the listbox which is in form1.

      Comment

      Working...