예제 #1
0
 private void ClearCheckedList(DevExpress.XtraEditors.CheckedListBoxControl control)
 {
     //Clear Item List
     control.Refresh();
     for (int i=0;i<control.Items.Count;i++)
         control.SetItemChecked(i,false);
 }
예제 #2
0
        private void SetCheckedListValue(DevExpress.XtraEditors.CheckedListBoxControl control,string strSQL,string target)
        {
            //Clear Item List
            control.Refresh();
            for (int i=0;i<control.Items.Count;i++)
                control.SetItemChecked(i,false);

            DataSet _ds = new DataSet();
            SqlHelper.FillDataset(connection,CommandType.StoredProcedure,"UP_GETDATA",_ds,new string[] {"table"}, new SqlParameter("@strSQL", strSQL) );

            DataView dv;
            dv = _ds.Tables["table"].DefaultView;

            //set check value
            try
            {
                for (int i=0; i< dv.Count; i++ )
                {
                    for (int j=0; j<control.ItemCount; j++)
                    {
                        if (dv[i].Row[target].ToString()== control.GetItemValue(j).ToString())
                        {
                            control.SetItemChecked(j,true);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }