Hi I have this strange problem concerning datagridview.
I have build an aplication which has a datagridview in which I add data stored in a file. When the application starts up I call a function that adds data to the datagridview and after that I change the color of specific cells in the datagridview like this:
public Form1()
{
//default function added by the application
//all initialization of buttons datagrids and so on are set here.
InitializeComponent();
//Add data to the grid, reads data from file and adds them
AddDataToTable(myDataGridView);
//Change color of cells in datagridview
ChangeColorOfData(myDataGridView);
}
The data is set just fine but the color won't change,
I use the following to set the backcolor:
myDataGridView.Rows.Cells[k].Style.BackColor = Color.DeepSkyBlue;
But if the user later interacts with the application and presses a button which calls the ChangeColorOfData function the datagridview cells updates, why does this happen???
Why won't it change during startup.
I have the same problem with the height of the cells, but I solved it by setting the rowtemplate.Height for the datagridView. Seems that the datagridview takes default values and won't update any changes that will change a default value... but they are update if I for example press a button as this:
private void Form1_Resize(object sender, EventArgs e)
{
ChangeColorOfData(myDataGridView);
}
Can someone help me?
I have build an aplication which has a datagridview in which I add data stored in a file. When the application starts up I call a function that adds data to the datagridview and after that I change the color of specific cells in the datagridview like this:
public Form1()
{
//default function added by the application
//all initialization of buttons datagrids and so on are set here.
InitializeComponent();
//Add data to the grid, reads data from file and adds them
AddDataToTable(myDataGridView);
//Change color of cells in datagridview
ChangeColorOfData(myDataGridView);
}
The data is set just fine but the color won't change,
I use the following to set the backcolor:
myDataGridView.Rows.Cells[k].Style.BackColor = Color.DeepSkyBlue;
But if the user later interacts with the application and presses a button which calls the ChangeColorOfData function the datagridview cells updates, why does this happen???
Why won't it change during startup.
I have the same problem with the height of the cells, but I solved it by setting the rowtemplate.Height for the datagridView. Seems that the datagridview takes default values and won't update any changes that will change a default value... but they are update if I for example press a button as this:
private void Form1_Resize(object sender, EventArgs e)
{
ChangeColorOfData(myDataGridView);
}
Can someone help me?