DataGridTextBox.SetDataGrid(DataGrid) Method

Definition

Sets the DataGrid to which this TextBox control belongs.

public void SetDataGrid(System.Windows.Forms.DataGrid parentGrid);

Parameters

parentGrid
DataGrid

The DataGrid control that hosts the control.

Examples

The following code example demonstrates the use of this member.

// Create a DataSet with a table and populate it.
private void MakeDataSet()
{
   myDataSet = new DataSet("myDataSet");

   DataTable tPer = new DataTable("Person");

   DataColumn cPerName = new DataColumn("PersonName");
   tPer.Columns.Add(cPerName);

   myDataSet.Tables.Add(tPer);

   DataRow newRow1;

   for(int i = 1; i < 6; i++)
   {
      newRow1 = tPer.NewRow();
      tPer.Rows.Add(newRow1);
   }

   tPer.Rows[0]["PersonName"] = "Robert";
   tPer.Rows[1]["PersonName"] = "Michael";
   tPer.Rows[2]["PersonName"] = "John";
   tPer.Rows[3]["PersonName"] = "Walter";
   tPer.Rows[4]["PersonName"] = "Simon";

   // Bind the 'DataSet' to the 'DataGrid'.
   myDataGrid.SetDataBinding(myDataSet, "Person");
   myDataGridTextBox.DataBindings.Add("Text",myDataSet,"Person.PersonName");
   // Set the DataGrid to the DataGridTextBox.
   myDataGridTextBox.SetDataGrid(myDataGrid);
}

Applies to

Produkt Verze
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 10