How to work with BarEditItem and BarCheckItem in RibbonControl Winforms Devexpress ?

5.5k views Asked by At

I need CheckBox in RibbonControl and if it checked I need to perform some task if not checked I need to perform some other task. So I tried barCheckItem1 It is working properly what I expect but it is Displaying like Button I need exact CheckBox. So again I used barEditItem1 in this Item "CheckChanged" event is not available then if i write code in "EditValueChanged" event, if I check or Uncheck the event not fired. How to complete my task ? I need CheckBox with CheckedChanged Event.

2

There are 2 answers

0
Bit On

You have two ways to access the control itself:

One way is:

CheckEdit checkEdit = barEditItem.Edit as CheckEdit;
bool isChecked = checkEdit.Checked;

The other is the repository editor directly:

 bool isChecked = repositoryItemCheckedEdit.ValueChecked;

I hope this is helpful.

2
Sriram Sakthivel On

Is this what you need?

Add a BarEditItem with CheckEdit, attach event CheckedChanged of RepositoryItemCheckEdit. You're done.

private void repositoryItemCheckEdit1_CheckedChanged(object sender, EventArgs e)
{
    Console.WriteLine(((CheckEdit) sender).Checked);
}

private void button1_Click(object sender, EventArgs e)
{
     bool? ischecked = (bool?)barEditItem1.EditValue;
     if(!ischecked.HasValue)
     {
       //In determinate state
     }
     else
     {
       if(ischecked.Value)
       {
           //Checked
       }
       else
       {
           //Not Checked
       }
     }
}