Click here to Skip to main content
12,703,063 members (29,111 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
Hi friends,

I am developing windows application. In checkboxlist there is no method for binding sql data. how can do it.
Thank in advance
Posted 4-Dec-12 0:27am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Please Check this. (source MSDN)

class MyClass
{
private string yesno;
public string YesNo
{
get { return yesno; }
set { yesno = value; }
}
}

private void Form1_Load(object sender, EventArgs e)
{

MyClass obj = new MyClass { YesNo = "Y" };
Binding b = new Binding("Checked", obj, "YesNo");
b.Format += new ConvertEventHandler(b_Format);
this.checkBox1.DataBindings.Add(b);

}

void b_Format(object sender, ConvertEventArgs e)
{
Binding b = sender as Binding;
CheckBox chk = b.Control as CheckBox;
if (e.Value.Equals("Y"))
chk.Checked = true;
else
chk.Checked = false;

}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170118.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100