DataGridViewClipboardCopyMode 列挙体
.NET Framework 3.0
DataGridView コントロールからクリップボードに内容をコピーするかどうかを示す定数を定義します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
| メンバ名 | 説明 | |
|---|---|---|
| Disable | クリップボードへのコピーは無効です。 | |
| EnableAlwaysIncludeHeaderText | 選択されたセルのテキスト値をクリップボードにコピーできます。選択されたセルを含む行および列のヘッダー テキストも含まれます。 | |
| EnableWithAutoHeaderText | 選択されたセルのテキスト値をクリップボードにコピーできます。選択されたセルを含む行または列の行ヘッダーまたは列ヘッダー テキストは、DataGridView.SelectionMode プロパティが RowHeaderSelect または ColumnHeaderSelect に設定されており、1 つ以上のヘッダーが選択されている場合にのみ含まれます。 | |
| EnableWithoutHeaderText | 選択されたセルのテキスト値をクリップボードにコピーできます。ヘッダー テキストは含まれません。 |
この列挙体は、ClipboardCopyMode プロパティで使用され、ユーザーが選択されたセルのテキスト値をクリップボードにコピーできるかどうか、および行ヘッダーと列ヘッダーのテキストを含めるかどうかを示します。
DataGridView コントロールでコピーを有効にする方法を次のコード例に示します。コード例全体については、「方法 : ユーザーが、Windows フォーム DataGridView コントロールからクリップボードに複数のセルをコピーできるようにする」を参照してください。
private void Form1_Load(object sender, System.EventArgs e) { // Initialize the DataGridView control. this.DataGridView1.ColumnCount = 5; this.DataGridView1.Rows.Add(new string[] { "A", "B", "C", "D", "E" }); this.DataGridView1.Rows.Add(new string[] { "F", "G", "H", "I", "J" }); this.DataGridView1.Rows.Add(new string[] { "K", "L", "M", "N", "O" }); this.DataGridView1.Rows.Add(new string[] { "P", "Q", "R", "S", "T" }); this.DataGridView1.Rows.Add(new string[] { "U", "V", "W", "X", "Y" }); this.DataGridView1.AutoResizeColumns(); this.DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; } private void PasteButton_Click(object sender, System.EventArgs e) { if (this.DataGridView1 .GetCellCount(DataGridViewElementStates.Selected) > 0) { try { // Add the selection to the clipboard. Clipboard.SetDataObject( this.DataGridView1.GetClipboardContent()); // Replace the text box contents with the clipboard text. this.TextBox1.Text = Clipboard.GetText(); } catch (System.Runtime.InteropServices.ExternalException) { this.TextBox1.Text = "The Clipboard could not be accessed. Please try again."; } } }
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。