i have a checkbox(chkBoxMgr) on a windows form that i have already linked to a bindingsource(staffBindingSource).

the value on the Staff table for the Mananger field is a "Y" how do i get the chkBoxMgr checkbox in a CHECKED state seeing that the value of the Manager field on the Staff table is a "Y" ????

staffData is my Dataset.
my code:

Binding b = new Binding("Checked", staffData, "Retail");  //staffData is my dataset but gives error 
        b.Format += new ConvertEventHandler(MyFormat);    //get error
        b.Parse += MyParse();  //get error
        ChkBoxRetail.DataBindings.Add(b); //get error
private void MyFormat(Object sender, ConvertEventArgs e)
        {
    if ((String)e.Value == "Y")
    {
        e.Value = true;
    } 
    else 
    {
       e.Value = false;
    }
}

public void MyParse(Object sender, ConvertEventArgs e) 
{
    if ((bool)e.Value == true)
    {
       e.Value = "Y";
    }
    else
    {
       e.Value = "N";
    }
}

can any one help me with the first 4 lines it is not correct
thanks
helloise

Recommended Answers

All 3 Replies

perhaps we could help if you shared more of the error.. like what it said.

line 2 and 3 errors:
1. method must have a return type
2. Invalid token '+=' in class, struct, or interface member declaration
4th line error:
Invalid token '(' in class, struct, or interface member declaration
Invalid token ')' in class, struct, or interface member declaration

thanks
helloise

Odd
I dont get the errors you do, in fact nothing like
The only error I get is with the line

b.Parse += MyParse();  //get error

where it tells me there is no "MyParse" with no parameters. If I just remove the () it actually compiles - as I would expect.

However, I believe the line should read:

b.Parse += new ConvertEventHandler(MyParse);

because your code is not exactly as you've listed it - eg you've pulled the Binding b code out of somewhere else, Im going to suggest that something else is wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.