R
Robert Pettersson
Hi,
I have a datagrid that I load some data into through a dataset.
Then I have som other controles, textboxes, where I can enter new posts into
my result, database.
When I have enterd a new post, I want to reload the data in the datagrid and
select the added post. Everything works fine exept the text that is kind of
selected. It´s not really selected beacuse i progamatically select another
row, that get blue. This cell is grey and the text in it is not updated
untill I click another cell. So if I scroll up and down in my datagrid the
previous cell that was selected before thae update of the datagrid is still
semiselected and "replaces" the data of the other cells as long as it is on
top of them.
Hope that you understand my problem.
This is some of my code that I use to update and reload my datagrid:
//Reload the data into the datagrid
dataGridDiscountHolders.DataSource = null;
dataGridDiscountHolders.DataBindings.Clear();
DataSet mDiscountHolders = new DataSet("DiscountHolders");
mDiscountHolders = SQLGetData.getDiscountHolders(); //This method returns
my dataset
mDiscountHolders.Tables[0].TableName = "DiscountHolders";
dataGridDiscountHolders.DataSource = mDiscountHolders.Tables[0];
//Set my newly added row to selected, var newlyAddedRow contains that id,
this part works fine.
for(int i = 0; i <
((DataTable)dataGridDiscountHolders.DataSource).Rows.Count; i++)
{
if(Convert.ToInt32(((DataTable)dataGridDiscountHolders.DataSource).Rows[0].ToString())== newlyAddedRow) { dataGridDiscountHolders.Select(i); dataGridDiscountHolders.CurrentRowIndex = i; } else dataGridDiscountHolders.UnSelect(i);}dataGridDiscountHolders.Update();dataGridDiscountHolders.Refresh();If anyone could give me some tips to remove the previous selected text, Iwould be very greateful!/Robert
I have a datagrid that I load some data into through a dataset.
Then I have som other controles, textboxes, where I can enter new posts into
my result, database.
When I have enterd a new post, I want to reload the data in the datagrid and
select the added post. Everything works fine exept the text that is kind of
selected. It´s not really selected beacuse i progamatically select another
row, that get blue. This cell is grey and the text in it is not updated
untill I click another cell. So if I scroll up and down in my datagrid the
previous cell that was selected before thae update of the datagrid is still
semiselected and "replaces" the data of the other cells as long as it is on
top of them.
Hope that you understand my problem.
This is some of my code that I use to update and reload my datagrid:
//Reload the data into the datagrid
dataGridDiscountHolders.DataSource = null;
dataGridDiscountHolders.DataBindings.Clear();
DataSet mDiscountHolders = new DataSet("DiscountHolders");
mDiscountHolders = SQLGetData.getDiscountHolders(); //This method returns
my dataset
mDiscountHolders.Tables[0].TableName = "DiscountHolders";
dataGridDiscountHolders.DataSource = mDiscountHolders.Tables[0];
//Set my newly added row to selected, var newlyAddedRow contains that id,
this part works fine.
for(int i = 0; i <
((DataTable)dataGridDiscountHolders.DataSource).Rows.Count; i++)
{
if(Convert.ToInt32(((DataTable)dataGridDiscountHolders.DataSource).Rows[0].ToString())== newlyAddedRow) { dataGridDiscountHolders.Select(i); dataGridDiscountHolders.CurrentRowIndex = i; } else dataGridDiscountHolders.UnSelect(i);}dataGridDiscountHolders.Update();dataGridDiscountHolders.Refresh();If anyone could give me some tips to remove the previous selected text, Iwould be very greateful!/Robert