Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ResetSelection 1

Status
Not open for further replies.

JCV

Programmer
Mar 14, 2002
33
AR
I need reset the previous selections makes in my datagrid.
How i use the "protected void ResetSelection" ?

I use : datagrid1.ResetSelection();

and the error is :
(765): 'System.Windows.Forms.DataGrid.ResetSelection()' no es accesible debido a su nivel de protección

Thanks.
JCV
 
You can access the protected member from a derived instance of the DataGrid.
Here is an example:
Code:
public class MyGrid: System.Windows.Forms.DataGrid
{
	public MyGrid()
	{
	}
	public void ResetSel()
	{
		base.ResetSelection();
	}
}

Code:
public class Form1 : System.Windows.Forms.Form
{
private MyGrid dataGrid1;
private System.ComponentModel.Container components = null;
public Form1()
	{
		InitializeComponent();
	}
private void InitializeComponent()
	{
		this.dataGrid1 = new MyGrid();
		//...
		this.dataGrid1.DataMember = "";
		this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
		this.dataGrid1.Location = new System.Drawing.Point(24, 160);
		this.dataGrid1.Name = "dataGrid1";
		this.dataGrid1.Size = new System.Drawing.Size(232, 80);
		this.dataGrid1.TabIndex = 2;
		this.dataGrid1.BackColorChanged += new System.EventHandler(this.dataGrid1_BackColorChanged);
		//..
		
		this.Controls.Add(this.dataGrid1);
		//..
		
	}
private void dataGrid1_BackColorChanged(object sender, System.EventArgs e)
	{
		MyGrid dg = (MyGrid)sender;
		dg.ResetSel();

	}
}
obislavu
 
ok, but can i put this into a button ?
Reset the selections makes in my datagrid, on click on a button in my form.
Thanks.
 
Yes,
Code:
private void btnGo_Click(object sender, System.EventArgs e)
{
this.dataGrid1.ResetSel();
}
where btnGo is a buuton on the form where dataGrid1 is a member of MyGrid type.
obislavu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top