One way you could try to do thus is to turn on the VirtualMode and use
CellValueNeeded to provide values for the unbound column. If you drop
a DataGridView on a form and add a Form.Load event with this code, you
can see a popilated unbound column in the grid.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
#region Get the DataSource
DataTable dt = new DataTable("MyTable");
int nCols = 4;
int nRows = 10;
for (int i = 0; i < nCols; i++)
dt.Columns.Add(new DataColumn(string.Format("Col{0}",
i)));
for (int i = 0; i < nRows; ++i)
{
DataRow dr = dt.NewRow();
for (int j = 0; j < nCols; j++)
dr[j] = string.Format("row{0} col{1}", i, j);
dt.Rows.Add(dr);
}
#endregion
this.dataGridView1.DataSource = dt;
DataGridViewTextBoxColumn col = new
DataGridViewTextBoxColumn();
col.Name = "UnBound";
col.HeaderText = "unbound";
this.dataGridView1.Columns.Add(col);
this.dataGridView1.VirtualMode = true;
this.dataGridView1.CellValueNeeded += new
DataGridViewCellValueEventHandler(dataGridView1_CellValueNeeded);
}
void dataGridView1_CellValueNeeded(object sender,
DataGridViewCellValueEventArgs e)
{
if (this.dataGridView1.Columns[e.ColumnIndex].Name ==
"UnBound")
{
e.Value = 100 * e.RowIndex + e.ColumnIndex;
}
}
}
==================
Clay Burch
Syncfusion, Inc.