GridControl 粘贴板功能
using DevExpress.Utils;using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
private void CopyTitle()
{
StringBuilder stringBuilder = new StringBuilder();
StringBuilder stringBuilder2 = new StringBuilder();
foreach (GridColumn gridColumn in this.gridView1.Columns)
{
if (gridColumn.Visible)
{
stringBuilder.AppendFormat("{0} ", gridColumn.Caption);
}
}
int[] selectedRows = this.gridView1.GetSelectedRows();
int[] array = selectedRows;
for (int i = 0; i < array.Length; i++)
{
int rowHandle = array;
foreach (GridColumn gridColumn in this.gridView1.Columns)
{
if (gridColumn.Visible)
{
stringBuilder2.AppendFormat("{0} ", this.gridView1.GetRowCellDisplayText(rowHandle, gridColumn.FieldName));
}
}
stringBuilder2.AppendLine();
}
Clipboard.SetText(stringBuilder.ToString() + "\r\n" + stringBuilder2.ToString());
}
页:
[1]