GridGrouping Control, Read only Rows

Hi, I want to know how you set rows to be read only. I know I can set columns to read only using: Me.groupingdatagrid1.TableDescriptor.Columns.Item(0).ReadOnly = True but i can''t seem to find any way to make rows read only. If any of you know, please let me know. Thanks, Paul

3 Replies

AD Administrator Syncfusion Team October 18, 2004 07:27 PM UTC

You can do this handling QueryCellStyleInfo. In the handler, explicitly set e.Style.ReadOnly = true based on whatever criteria you need. This code sets a row readonly is the AAs field value is AAA4.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
	if(e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
		|| e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)
	{
		GridTableDescriptor td = this.gridGroupingControl1.TableDescriptor;
		GridRecordRow rec = e.TableCellIdentity.DisplayElement as GridRecordRow;
		if(rec != null)
		{
			DataRowView drv = rec.GetData() as DataRowView;
			if(drv != null && drv["AAs"].ToString() == "AA4")
			{
				e.Style.ReadOnly = true;
			}
		}
	}
}


PA Paul October 19, 2004 01:35 AM UTC

Thanks for the function. I couldnt port it to VB.net, could you paste in a vb version?? also, will this work with a currency field. Thanks


AD Administrator Syncfusion Team October 19, 2004 05:33 AM UTC

It should work for any cell type. Here is a link that does a pretty good job of converting C# to VB. http://authors.aspalliance.com/aldotnet/examples/translate.aspx
Private Sub gridGroupingControl1_QueryCellStyleInfo(sender As Object, e As GridTableCellStyleInfoEventArgs)
   If e.TableCellIdentity.TableCellType = GridTableCellType.RecordFieldCell Or e.TableCellIdentity.TableCellType = GridTableCellType.AlternateRecordFieldCell Then
      Dim td As GridTableDescriptor = Me.gridGroupingControl1.TableDescriptor
      Dim rec As GridRecordRow = e.TableCellIdentity.DisplayElement ''
      If Not (rec Is Nothing) Then
         Dim drv As DataRowView = rec.GetData() ''
         If Not (drv Is Nothing) And drv("AAs").ToString() = "AA4" Then
            e.Style.ReadOnly = True
         End If
      End If
   End If
End Sub ''gridGroupingControl1_QueryCellStyleInfo

Loader.
Up arrow icon