Live Chat Icon For mobile
Live Chat Icon

How can I get text from a column header in a MouseUp event

Platform: WinForms| Category: Datagrid
	private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
	{
		System.Drawing.Point pt = new Point(e.X, e.Y);
		DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
		if(hti.Type == DataGrid.HitTestType.Cell) 
		{
			MessageBox.Show(dataGrid1[hti.Row, hti.Column].ToString());
		}
		else if(hti.Type == DataGrid.HitTestType.ColumnHeader) 
		{
			MessageBox.Show(((DataView) DataGrid1.DataSource).Table.Columns[hti.Column].ToString());
		}
	}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.