I have a gridview form.
Some guy set certain grid cell readonly, light gray color.
My question is:
How can I identify the row cell style directly?
How to Indetify a grid cell is readly only or not?
Answers
Hi,
Thank you for contacting us.
Appearance settings that are changed in the GridView.RowCellStyle event handler are not stored as cell properties.
As far as I understand, you have implemented the approach illustrated in the How to customize the Look-And-Feel of my grid cells KB article.
I.e., you have defined some rules that determine whether or not a current cell will be painted with the light-gray color, or whether or not an editor will be shown in the current cell.
From this point of view, I suggest you use the same rules to determine whether or not the current cell is read-only.
I have created a simple sample that illustrates my interpretation of your scenario. Please find it in the attachment.
If this is not your case, please provide us with your sample or modify mine so it illustrates your scenario and final goal. We will do our best to help you.
Hi,
If you define custom rules that determine whether or not a current sell is read-only in the GridView.ShowingEditor event, you can check a specific cell state using the GridView.CanShowEditor property value.
But this property gets a value indicating whether a View can activate an editor for a focused cell. Thus, you need to focus a specific cell before using this property. Look at the following code based on the sample I attached previously:
C#private void simpleButton1_Click(object sender, EventArgs e)
{
// saving focused cell information
GridColumn prevColumn = gridView1.FocusedColumn;
int prevRowHandle = gridView1.FocusedRowHandle;
gridView1.FocusedRowHandle = Convert.ToInt32(spinEdit1.EditValue);
gridView1.FocusedColumn = gridView1.Columns[comboBoxEdit1.EditValue.ToString()];
layoutControlItem2.Text = gridView1.CanShowEditor ? "REGULAR CELL" : "READ_ONLY";
// restoring focused cell information
gridView1.FocusedRowHandle = prevRowHandle;
gridView1.FocusedColumn = prevColumn;
}
I hope you find this information helpful.
You are welcome!
Should you have any questions regarding our products, do not hesitate to contact us.
Hi Zheng,
Thank you for your inquiry. From your message, it is not clear to me what technology you are using (WinForms, WPF, ASP.NET, Silverlight). Would you please clarify this?
Thanks for your response.
WinForms