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
close icon

Copying Column Headers (ColHeaders)

I have: this.grid.Model.CutPaste.ClipboardFlags |= GridDragDropFlags.ColHeader; set in my code. This works great when I select the entire grid and copy and paste into Excel. But when I select a single row (or anything but the entire grid), the column headers aren''t copied over. How can I make it so?

2 Replies

AD Administrator Syncfusion Team April 1, 2004 05:12 PM UTC

The column headers need to be part of the selections. If you are using ListBoxSelectionMode, this prevents the columns from being selected (unless you click cell 0,0 which selects the whole table); If you put a button handler with this code in a grid with ListBoxSelectionMode set, then it will select some header cells when you click the button, and then is you ctl+C to copy, it will copy the headers. 9Just to verify it works..) private void button1_Click(object sender, System.EventArgs e) { this.gridControl1.Selections.Add(GridRangeInfo.Cells(0,2,4,3)); this.gridControl1.Focus(); } So, copy headers is sort of a problem with ListBoxMode. You could handle ClipboardCopy event yourself, and put whatever you wanted on the clipboard.


AA Akshay Arora April 1, 2004 06:05 PM UTC

I managed to figure it out by finding some code that I had elsewhere. I guess I had forgotton about it. Random comment - is there anyway to make the Message box when writing a post bigger? This thing is like 2 rows high and 10 columns wide... For reference, this is what I did. this.dataGrid.Model.ClipboardCopy += new GridCutPasteEventHandler( this.HandleClipboadCopy ); private void HandleClipboadCopy( object sender, GridCutPasteEventArgs e ){ e.ClipboardFlags |= GridDragDropFlags.ColHeader; for( int i = 0; i < this.dataGrid.DataBoundGridModel.Selections.Ranges.Count; i++ ){ e.RangeList.Add( GridRangeInfo.Cell( 0, this.dataGrid.DataBoundGridModel.Selections.Ranges[ i ].Left ) ); } }

Loader.
Live Chat Icon For mobile
Up arrow icon