Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy/Paste functionality for DataGridView
Message
From
27/01/2007 18:47:37
 
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
Copy/Paste functionality for DataGridView
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01189883
Message ID:
01189883
Views:
196
UT magazine contains Cut() etc. implementation solution provided by Bonnie Berent in Message #696109

This is not working in case of DataGridView.

How to implement cut/paste etc. edit menu also in case of DatagridView ?

Here s repro of the issue

Observed:

first column is not empty

Expected:

first column must be empty

Code to reproduce:
using System.Windows.Forms;
using System.Data;
static class Program {
	static void Main() {
		Application.Run(new Frm());
	}
}

class Frm : Form {
	public Frm() {
		//this works: DataGrid dataGrid1 = new DataGrid();
		DataGridView dataGrid1 = new DataGridView();
		DataTable t = new DataTable();
		t.Columns.Add();
		t.Columns.Add();
		t.Rows.Add("111111", "222222");
		dataGrid1.DataSource = t;
		dataGrid1.Dock = DockStyle.Fill;
		Controls.Add(dataGrid1);
	}

	protected override void OnActivated(System.EventArgs e) {
		base.OnActivated(e);
		Control o = ActiveForm;

		while (o is ContainerControl) {
			ContainerControl oContainer = (ContainerControl)o;
			o = oContainer.ActiveControl;
		}
		if (o != null && o is TextBox)
			((TextBox)o).Cut();
		SendKeys.SendWait("{TAB}");
	}
}
Andrus
Next
Reply
Map
View

Click here to load this message in the networking platform