Zakir Ahamed

Zakir Ahamed

  • NA
  • 1.4k
  • 627.4k

i need to check Multicheckedlistbox with checked items

Jul 21 2017 7:20 AM
hi friends,
 
i am developing winforms i have issue:
 
this is my code:
 
private void GvCategory_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
indexRow = e.RowIndex;
DataGridViewRow row = GvCategory.Rows[indexRow];
txtcategory.Text = row.Cells[1].Value.ToString();
//txtcategory.ReadOnly = true;
btncategory.Text = "Update";
rbyes.Checked = true;
if (txtcategory.Text != " ")
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RetailTestConnection"].ConnectionString);
con.Open();
string query = String.Format("Select [Item_Id]='{0}' order by Item_Id", Convert.ToInt32(txtcategory.Text));
SqlCommand cmd = new SqlCommand(query,con);
SqlDataReader dr = cmd.ExecuteReader();
string[] s = new string[] { };
while (dr.Read())
{
s = dr.ToString().Split(',');
}
int Length = s.Length;
for (int i = 0; i < Length; i++)
// for (int i = 0; i <= 1; i++)
{
string fetr = s[i];
for (int j = 0; j <= clbbrand.Items.Count - 1; j++)
{
if (clbbrand.Items[j].ToString() == s[i])
{
clbbrand.SetItemChecked(j, true);
break;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
 
 
the list value is not geting , how i get the values to showed a checkbox saved and updated in time whatever values i saved i will showed in already i will cheked items..
 
i need immediate reply... 

Answers (5)