ÇáãÓÇÚÏ ÇáÔÎÕí ÇáÑÞãí

ãÔÇåÏÉ ÇáäÓÎÉ ßÇãáÉ : How to change the button's value in Datagrid



C# Programming
10-07-2009, 12:10 PM
Hi Everyone,

I am using button's obj in datagridview and set the flag as true to show the text value of the button (Name of the Button). If user clicks on the button, its changes the button’s name based upon the criteria. I am doing very simple code here.

I set button’s name as “buttonColumn.UseColumnTextForButtonValue = true;”

Now If I want to change the value with following settings. It did not work it out.

dataGridView1[e.ColumnIndex, e.RowIndex].Value = "America"; It is still taking "Name"

Can you please help me on this?

private void CreateButtonColumn()
{
// Initialize the button column.
DataGridViewButtonColumn buttonColumn = new DataGridViewButtonColumn();
// Add the button column to the control.


buttonColumn = new DataGridViewButtonColumn();

buttonColumn.Name = "Name";
buttonColumn.Text = "Name";
buttonColumn.Width = 110;
buttonColumn.UseColumnTextForButtonValue = true;
dataGridView1.Columns.Insert(0, buttonColumn);
dataGridView1.Rows.Add(2);
dataGridView1.CellClick += new DataGridViewCellEventHandler(dataGridView1_CellClick);
}

void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToInt32(e.ColumnIndex) == 0)
{
dataGridView1[e.ColumnIndex, e.RowIndex].Value = "America";
}
}


Thanks.