views:

1109

answers:

1

Hello,

I use the code below to access the properties on my form,but today I'd like to write stuff to a ListView,which requires more parameters.

    public string TextValue
    {
        set
        {
            if (this.Memo.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate
                {
                    this.Memo.Text += value + "\n";
                });
            }
            else
            {
                this.Memo.Text += value + "\n";
            }
        }
    }

How to add more than one parameter and how to use them(value,value)?

+5  A: 

(edit - I think I misunderstood the original question)

Simply make it a method instead of a property:

public void DoSomething(string foo, int bar)
{
    if (this.InvokeRequired) {
        this.Invoke((MethodInvoker)delegate {
            DoSomething(foo,bar);
        });
        return;
    }
    // do something with foo and bar
    this.Text = foo;
    Console.WriteLine(bar);
}
Marc Gravell