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. Image for the cookie policy date

Transposing cells . .(like Excel)

i am building a grid (using GridControl) where some users want to see the data in Rows and other user want to see the data in Columns. I would like the grid to have a toggle so users can switch back and forth. is there any example or any help that would help me in the right direction. thanks, ak

3 Replies

AD Administrator Syncfusion Team July 7, 2005 06:47 PM

You can use the virtual events to swap the roles of the rows and columns. Here is a little sample for a GridControl. http://www.syncfusion.com/Support/user/uploads/GC_FlipRowsColumns_d41c0bf6.zip


AK Adam K. July 8, 2005 12:21 PM

Clay, I am using your code but it looks like i am getting a bunch of exceptions in the grid because it seems to be really slow for me. i have attached my project. thanks, ak >You can use the virtual events to swap the roles of the rows and columns. Here is a little sample for a GridControl. > >http://www.syncfusion.com/Support/user/uploads/GC_FlipRowsColumns_d41c0bf6.zip > > BookingTester_1712.zip


AD Administrator Syncfusion Team July 8, 2005 06:59 PM

The exception is being caused by the fact that not all your grid cells are populated. You have to add a check to querycellinfo to avoid trying to use a null GridStyleInfoStore. Also, you are using the row and column headers. In this case, you would need to use row and col zero in the event as well.
private void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
	if(_flipped && e.ColIndex > -1 && e.RowIndex > -1)
	{
		if(this.gridControl1.Data[e.ColIndex, e.RowIndex] != null)
		{
			e.Style.ModifyStyle(this.gridControl1.Data[e.ColIndex, e.RowIndex], Syncfusion.Styles.StyleModifyType.Override);
		}
		e.Handled = true;
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon