Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid column header *SORTED* Property/Event?

Status
Not open for further replies.

DanEvansJr

Programmer
Aug 17, 2001
41
US
I'm new to C# (Old XBASE/FoxPro guy). I have a relatively simple C# application. One form, some fields, and a grid.

I was able to get help here for rebinding my dataset after a column sort/re-sort, but now I need some other assistance. I use a 'search' field so that users can find records by unique record ID, Employee SSN, or employee name. I'd like the search to be based on whatever the grid column order is.

EX: User clicks SSN Grid column, now all records are in SSN order. After some simple validation for that search field, I'd like to search through the SSN column of the dataset.

In the FoxPro world, there is a click event for the grid column headers. Is there such a thing in C#? and if so, where is it??

Thanks in advance to anyone who can help me.
 
You can check for clicks on a datagrid column header by using HitTestInfo:
Code:
		private void dataGrid1_Click(object sender, System.EventArgs e)
		{
			DataGrid.HitTestInfo hti = dataGrid1.HitTest(dataGrid1.PointToClient(Cursor.Position));

			if (hti.Type == DataGrid.HitTestType.ColumnHeader)
			{
				//Mouse click on column header
				Console.WriteLine("Column {0} header clicked", hti.Column);
			}
		}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top