Hi,
There is an event called "ColumnHeaderMouseClick" in Windows.Forms.DataGridView. is there any similar event
available with UltraWinGrid.UltraGrid ?
No, there is not event that notifies of a single click (there is, however, a DoubleClickHeader event). Note that you could handle the control's MouseClick event and hit test for a column header.
Example:void ultraGrid_MouseClick(object sender, MouseEventArgs e){ UltraGrid grid = sender as UltraGrid; UIElement controlElement = grid.DisplayLayout.UIElement; UIElement elementAtPoint = controlElement != null ? controlElement.ElementFromPoint(e.Location) : null; UltraGridColumn column = null; while ( elementAtPoint != null ) { HeaderUIElement headerElement = elementAtPoint as HeaderUIElement; if ( headerElement != null && headerElement.Header is Infragistics.Win.UltraWinGrid.ColumnHeader ) { column = headerElement.GetContext( typeof(UltraGridColumn) ) as UltraGridColumn; break; }
elementAtPoint = elementAtPoint.Parent; }}
Solution suggested by you is working , but it takes long time to execute that event.
My requirement is when user click on any of the column of the grid and he can apply cut,paste,copy functionality.
but cut,copy,paste functionality is working with selected cells. if i will implement this method its working fine. but its taking long time.
is there any other solution to this problem ?
Thanks in Advance.
No, there's no way to set a range of cells all at once.
I'm having similar problem and i've tried to use BeginUpdate/EndUpdate - still it is very slow. Is there a way to get collection of all cells in the column, so Selected.Cell.AddRange() can be used?
Looping through every row in the grid like you are doing here is probably what is taking the time, not the code that is posted above.
You should check out the WinGrid Performance Guide to see how you can do this more efficiently.
Please find the attached file having the code snipest. Main goal to add the particular logic is to enable cut,copy,paste
functionality on click of Column Header. HeaderClickAction to Select is already set.
Exactly what code is taking a long time?
The code that Brian posted above should not take any time at all. It's instantaneous on my machine.
If you just want to select a column and copy the cells, then you could simply set the HeaderClickAction to Select to allow the user to select a column. And then set AllowMultiCellOperation to allow copy and paste.