2

I have a devexpress gridview, and in one of the columns is a checkbox. I want to check to see if the checkbox in that column is selected in the focused row, and if so, perform some action. How should I go about checking if the checkbox is checked?

2
  • Please post the code for this. Commented Feb 28, 2013 at 19:30
  • Do you use data-bindings? Adding some code would help us. I don't know the technologies, where DevExpress grids are available for. WPF? Silverlight? ASP.NET? WinForms? Commented Feb 28, 2013 at 20:04

4 Answers 4

2
   bool value = (bool) gridView.GetRowCellValue(gridView.FocusedRowHandle, column);
Sign up to request clarification or add additional context in comments.

Comments

0

If you are using DataBinding it is very easy. For example:

public class MyClass(){
   public MyClass(){

   }

   public bool IsTrue
   {
     get{;}
     set{;}
   }
}

List<MyClass> manyMyClassObjects = new List<MyClass>();
//Add some values for sure

GridControl.DataSource = manyMyClassObjects;

Now the IsTrue property is binded to the Grid. The GridView just present the underlaying Data. If you change a value in the Grid it changes the value of your DataSource Object. This will work with any Property which implements a setter for sure.

Comments

0
DataRow[] rows = new DataRow[gvExcelSheet.RowCount];
                for (int j = 0; j < gvExcelSheet.RowCount; j++)
                {
                    rows[j] = gvExcelSheet.GetDataRow(j);
                    if ((bool)rows[j]["yourcheckboxcolumnname"] == true)
                    {
                        //your code
                    }
                }

Comments

0

Simple as below:

bool value = Convert.ToBoolean(gvMain.SelectedRowsCount);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.