I am not cutting and pasting the contents.
Everytime i m removing the column from the GridBoundColumnsCollection and inserting when required.
But the content of the header row is deleted.I am not doing anything specific for other rows of the columns
I have attached the function for cut and insert.
Also is there any better way of doing this?
///
/// Cuts the selected columns
///
///
///
///
private void m_MenuItemCutCols_ClickEventHandler(
object sender, EventArgs e )
{
m_HasCutColCalled = true;
GridBoundColumnsCollection col = (GridBoundColumnsCollection)
this.m_PretestListingGrid.GridBoundColumns.Clone();
if (col.Count == 0)
col = this.m_PretestListingGrid.Binder.InternalColumns;
this.m_PretestListingGrid.GridBoundColumns.Clear();
//Contains the list of the cut columns
m_CutCols.Clear();
//Get the selected columns range
GridRangeInfoList ranges = null;
this.m_PretestListingGrid.Selections.GetSelectedRanges(
out ranges, false);
ArrayList colsHeadersToRm = new ArrayList();
foreach (GridRangeInfo range in ranges)
{
switch (range.RangeType)
{
case GridRangeInfoType.Cells:
if (!colsHeadersToRm.Contains(range.Left - 1))
{
colsHeadersToRm.Add(range.Left - 1);
}
break;
case GridRangeInfoType.Cols:
if (!colsHeadersToRm.Contains(range.Right - 1))
{
colsHeadersToRm.Add(range.Right - 1);
}
if (!colsHeadersToRm.Contains(range.Left - 1 ))
{
colsHeadersToRm.Add(range.Left - 1);
}
break;
}
}
if (!colsHeadersToRm.Contains(m_LastCol - 1))
{
colsHeadersToRm.Add(m_LastCol - 1);
}
colsHeadersToRm.Sort();
for (int i = 0; i < col.Count; i++)
{
bool bCutCell = false;
GridBoundColumn column = col[i];
for (int j = 0;j < colsHeadersToRm.Count; j++)
{
if ((int)colsHeadersToRm[j] == i)
{
//Add the cut columns
m_CutCols.Add(column);
bCutCell = true;
}
}
if ( bCutCell == false)
{
this.m_PretestListingGrid.GridBoundColumns.Add(column);
}
}
if (m_HasCutColCalled == true)
{
this.m_MenuItemInsertCutCol.Enabled = true;
}
m_PretestListingGrid.Binder.InitializeColumns();
for (int m = 0; m < m_HiddenCols.Count; m++)
{
GridBoundColumn column =(GridBoundColumn)m_HiddenCols[m];
int colIndex = GetPosition(column.HeaderText);
this.m_PretestListingGrid.Model.Cols.Hidden[colIndex] = true;
}
m_PretestListingGrid.Refresh();
return;
}
///
/// Insert cut columns
///
///
///
///
private void m_MenuItemInsertCutCol_ClickEventHandler(
object sender, EventArgs e )
{
GridBoundColumnsCollection col = (GridBoundColumnsCollection)
this.m_PretestListingGrid.GridBoundColumns.Clone();
if (col.Count == 0)
col = this.m_PretestListingGrid.Binder.InternalColumns;
this.m_PretestListingGrid.GridBoundColumns.Clear();
GridBoundColumn column = null;
this.m_PretestListingGrid.Model.Cols.Hidden.ResetRange(0,col.Count);
//Form the grid bound columns again and
//Add the cut column
for (int i = 0; i < col.Count; i++)
{
if (i == m_LastCol - 1 )
{
for (int j = 0;j < m_CutCols.Count; j++)
{
column = (Syncfusion.Windows.Forms.Grid.GridBoundColumn)
m_CutCols[j];
this.m_PretestListingGrid.GridBoundColumns.Add(column);
m_PretestListingGrid.Binder.InitializeColumns();
}
}
column = col[i];
this.m_PretestListingGrid.GridBoundColumns.Add(column);
m_PretestListingGrid.Binder.InitializeColumns();
}
//disable the insert cut column
this.m_MenuItemInsertCutCol.Enabled = false;
m_PretestListingGrid.Binder.InitializeColumns();
m_PretestListingGrid.Refresh();
for (int m = 0; m < m_HiddenCols.Count; m++)
{
GridBoundColumn gridCol =(GridBoundColumn)m_HiddenCols[m];
int colIndex = GetPosition(gridCol.HeaderText);
this.m_PretestListingGrid.Model.Cols.Hidden[colIndex] = true;
}
this.m_PretestListingGrid.Model.ColWidths.ResizeToFit(
GridRangeInfo.Row(0),GridResizeToFitOptions.IncludeHeaders);
m_HasCutColCalled = false;
return;
}
>If this is a GridDataBoundGrid (as opposed to a GridControl), the default paste only paste text information. It does not paste style information. So, is the inforamtion you are putting in your extra header held in the style.Text property for the cell? If not, the default paste will not work for you.
>
>You can handle the grid.Model.ClipboardPaste event and do what you want with teh data that is on the clipboard. You can also handle the ClipboardCopy event and put extra data into the clipboard as well.