Ranorex DataGridView: no ReadOnly, but has IsReadOnly?
Posted: Mon Aug 01, 2011 6:46 pm
I am trying to verify that all cells of a table (DataGridView) are ReadOnly. I am unable to get "ReadOnly" as an option for the cells of the repository grid. It does have "IsReadOnly" available though. Is this expected, or am I missing something? I just would have thought that it would have exactly the same attributes as the .NET object. For a text field, I can use "ReadOnly" just fine.
Also, I am unable to use this IsReadOnly attribute in a Validate statement. When I use the common "ReadOnly" attribute in a validate statement for a TEXT field, it works fine. But for "IsReadOnly", I get an error.
Below is a sample of how I was able to use "IsReadOnly". It works if I use it this way, I'm just not sure if this is the best way to get to the same result.
Thanks
Also, I am unable to use this IsReadOnly attribute in a Validate statement. When I use the common "ReadOnly" attribute in a validate statement for a TEXT field, it works fine. But for "IsReadOnly", I get an error.
Below is a sample of how I was able to use "IsReadOnly". It works if I use it this way, I'm just not sure if this is the best way to get to the same result.
public void CheckEditableFields() { Ranorex.Table myTable = repo.MyForm.TestFolder.MyGrid; for (int i = 1; i < myTable.Rows.Count; i++) { Ranorex.Row myRow = repo.MyForm.TestFolder.MyGrid.Rows; foreach (Ranorex.Cell myCell in myRow.Cells) { int mmIndex = myCell.Element.ChildIndex; // ----------- Check if cells are ReadOnly ----------- if (repo.MyForm.TestFolder.MyGrid.Rows.Cells[mmIndex].Enabled == true) { if (repo.MyForm.TestFolder.MyGrid.Rows.Cells[mmIndex].Element.Attributes.IsReadOnly == false) { Report.Info("Success: cell is Editable"); } else { Report.Failure("Failure: cell is ReadOnly."); } } else { Report.Failure("Failure: cell is Disabled."); } } } }
Thanks