Inside Man
Inside Man

Reputation: 4297

Expand one row at a Time in RadGridView - C# Telerik

I have a rad grid view with hierarchical template. User can expand each row, and in normal mode User can expand several rows. I need to prevent such behavior and let user to only expand one row at a time.

I searched in telerik forums and Google but did not find any helpful code working on winforms radgridview.

Upvotes: 0

Views: 1448

Answers (2)

rockat0311
rockat0311

Reputation: 36

Use radGridView's ChildViewExpanded event and a variable to store the last expanded row index

 int lastExpandedRow = -1;
 private void radGridView_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
 {
   int parentRowIndex = e.ParentRow.Index;
   if (lastExpandedRow != -1 && lastExpandedRow != parentRowIndex )
   {
      radGridView.Rows[lastExpandedRow].IsExpanded = false;
   }
   lastExpandedRow = parentRowIndex ;
 }

Upvotes: 2

Seano666
Seano666

Reputation: 2238

Capture the expanding event, and inside it collapse all the rows, so the newly expanded row will be the only one expanded.

Upvotes: 0

Related Questions