Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy/Paste functionality for DataGridView
Message
De
27/01/2007 18:47:37
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Copy/Paste functionality for DataGridView
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01189883
Message ID:
01189883
Vues:
197
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform