We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

GridGrouping Control, Read only Rows

Thread ID:





20415 Oct 17,2004 05:43 PM Oct 19,2004 01:33 AM Windows Forms 3
Tags: Grouping
Asked On October 17, 2004 05:43 PM

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

Administrator [Syncfusion]
Replied On October 18, 2004 03:27 PM

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;

Replied On October 18, 2004 09:35 PM

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

Administrator [Syncfusion]
Replied On October 19, 2004 01:33 AM

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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.