• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

How do I call a method from another method?

How do I call this...
        private void UpdateListBox(object sender, EventArgs e)
        {
        }
... from another method?
0
Antonio King
Asked:
Antonio King
1 Solution
 
jk_vrCommented:
If you want to access the method from same class itself , you can call like this

UpdateListBox(this, new EventArgs());
0
 
jimstarCommented:
If you aren't doing anything with "sender" or "e" in UpdateListBox, you can just pass in null to both.

UpdateListBox(0, 0);

If you actually use that data, then you need to get the listbox itself to trigger that event, which will pass sender and e properly.
0
 
Gautham JanardhanCommented:
UpdateListBox(sender,Eventargs.empty)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
is that method a member of a class? is that class a static class?
is the "other" method in the same class?

as the method is private, you can "only" call it from the same class.

you might want to specify what exactly is the "problem" you have, for example, what to pass as arguments?
0
 
Pratima PharandeCommented:
You can do like this

Whatever inside the updatelistbox ,put all that in new methid as it is NewMethod()
and call that from another method

  private void UpdateListBox(object sender, EventArgs e)
        {
             NewMethod()
        }

 NewMethod()
{
  //Code here
}

0
 
Jai STech ArchCommented:
it is much better to use
(this, new EventArgs()); rather than (0,0)
also if you want to pass your own event arguements ...
create a event arugment and assign it with your values and then pass it along...
EventArgs ev = new EventArgs(something);
(this,ev)
0
 
Antonio KingIT ManagerAuthor Commented:
Thanks all for your eager responses!
0
 
jimstarCommented:
>> it is much better to use
>> (this, new EventArgs()); rather than (0,0)

That depends on what they are doing inside of the event handler. If all that is occuring is setting a flag (bComplete = true), then it really doesn't matter. :) Of course, if they're using the args, then neither will help, since an empty arg set is arguably as useless as the null arg set (assuming you handle that).
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now