How to set the RecordPreviewCell in WinForms GridGroupingControl?
RecordPreviewCell
By
default, ShowRecordPreviewRow indicates whether the nested
table has preview row or not. The Celltype of the RecordPreviewCell can
be changed in the QueryCellStyleInfo event.
Solution:
To set a
particular Record Preview Row as the HTMLUI cell type, you can use Record class
to identify where to assign the HTMLUI control. By using this class, you can
get the Record ID. According to this ID, you can assign the CellType to
a particular Preview Row. The following code displays the same by using WinForms GridGroupingControl.
C#
//QuerCellStyleInfo Event hooked.
this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(grid_QueryCellStyleInfo);
void grid_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
rec = e.TableCellIdentity.DisplayElement.GetRecord();
//Specifies the needed Row.
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordPreviewCell)
{
e.Style.BackColor = Color.AliceBlue;
if (rec.Id == 3)
{
if (isrecordpreview)
{
//Celltype changed.
e.Style.CellType = GridCellTypeName.Control;
//HTMLUI control added.
e.Style.Control = htmluiControl1;
}
else
{
//Intially RecordPreviewCell is displayed with this text.
e.Style.Text = "Default RecordPreviewCell";
}
}
}
}
' QuerCellStyleInfo Event hooked.
AddHandler Me.gridGroupingControl1.QueryCellStyleInfo, AddressOf grid_QueryCellStyleInfo
Private Sub grid_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
Dim rec = e.TableCellIdentity.DisplayElement.GetRecord()
' Specifies the needed Row.
If e.TableCellIdentity.TableCellType = GridTableCellType.RecordPreviewCell Then
e.Style.BackColor = Color.AliceBlue
If rec.Id = 3 Then
If isrecordpreview Then
' CellType changed.
e.Style.CellType = GridCellTypeName.Control
' HTMLUI control added.
e.Style.Control = htmluiControl1
Else
' Initially RecordPreviewCell is displayed with this text.
e.Style.Text = "Default RecordPreviewCell"
End If
End If
End If
End Sub
Figure 1: Assign CellType
Figure 2: RecordPreviewCell type set as HTMLUI control
Conclusion
I hope you enjoyed learning about how to set the RecordPreviewCell type as a control in GridGroupingControl.
You can refer to our WinForms GridGroupingControl feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl documentation to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!