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.

Sort column on a databoundgrid

Thread ID:

Created:

Updated:

Platform:

Replies:

5107 Jun 19,2003 11:40 AM Jun 19,2003 03:59 PM Windows Forms 4
loading
Tags: GridControl
Russell Simmons
Asked On June 19, 2003 11:40 AM

What event gets fired when a user clicks on a column header to update the sort column and order? Also, the SortCol property allows the user to set a column for the sort order - is there a similar property that allows me to retrieve the current sort index? Thanks.

Administrator [Syncfusion]
Replied On June 19, 2003 01:58 PM

The CellClick event fires before the sort is done. Youwould check teh row index to make sure the click is on a header cell. The sort direction is stored in the header's cells style.Tag property. Here are code snippets that show how you can get at it.
private void button1_Click(object sender, System.EventArgs e)
{
	for(int i = 1; i <= this.gridDataBoundGrid1.Model.ColCount; ++i)
		if(this.gridDataBoundGrid1[0,i].Tag is ListSortDirection)
		{
			MessageBox.Show((i.ToString() + " " + this.gridDataBoundGrid1[0,i].Tag.ToString());
		}
	}
}

Russell Simmons
Replied On June 19, 2003 03:22 PM

What event fires after the sort is done? Unfortunately, it seems that when the CellClick event fires, the Tag property is not yet set. > The CellClick event fires before the sort is done. Youwould check teh row index to make sure the click is on a header cell. > > The sort direction is stored in the header's cells style.Tag property. Here are code snippets that show how you can get at it. >
> private void button1_Click(object sender, System.EventArgs e)
> {
> 	for(int i = 1; i <= this.gridDataBoundGrid1.Model.ColCount; ++i)
> 		if(this.gridDataBoundGrid1[0,i].Tag is ListSortDirection)
> 		{
> 			MessageBox.Show((i.ToString() + " " + this.gridDataBoundGrid1[0,i].Tag.ToString());
> 		}
> 	}
> }
> 

Administrator [Syncfusion]
Replied On June 19, 2003 03:41 PM

I am afraid there is no good event yo catch this action. To catch it, you can derive the GridDataBoundGrid and override the SortColumn virtual method.
Public Class DataBoundSortGrid
    Inherits GridDataBoundGrid


    Public Overrides Sub SortColumn(ByVal colIndex As Integer)

        MyBase.SortColumn(colIndex)
	Console.WriteLine("After Sort")

    End Sub

End Class

Russell Simmons
Replied On June 19, 2003 03:59 PM

Thank you. I figured out another way to do what I wanted to do. The info you sent was very helpful, though. > I am afraid there is no good event yo catch this action. To catch it, you can derive the GridDataBoundGrid and override the SortColumn virtual method. > >
> Public Class DataBoundSortGrid
>     Inherits GridDataBoundGrid
> 
> 
>     Public Overrides Sub SortColumn(ByVal colIndex As Integer)
> 
>         MyBase.SortColumn(colIndex)
> 	Console.WriteLine("After Sort")
> 
>     End Sub
> 
> End Class
> 
>

CONFIRMATION

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.

;