c# - how can I reset or refresh DataGridView Cell back color? -


I have a problem with regard to datagrid view cell re-color.

First of all, I am changing the back color of the specific cell of Datagrid View 2.

  int cnt = datagread view. Rows.Count; For {i.e. i = 0; i & lt; cnt; i ++} {string start = datagroup view 1. Rao [i]. Sel [9]. Value Toasting (); String Start = Convert. Toddime (beginner toastring) Toasting ("DD MMM Yay"); String Finish = Data Grid View 1. Rao [i]. Sel [10]. Value ToString (); String endings = convert toDateTime (ending.ToString ()). ToString ("dd MMM yyyy"); Timespane TS = Convert. Broken time (ending toaster) - convert Tudetime (start tostring ()); Dual diff = ts, pause + 1; Int dif = Convert toInt32 (diff); For (int d = 0; d & lt; dif; d ++) {string str = Convert toDateTime (start.ToString ()). AddDays (D). Ostring ("dd MMM yyyy"); DataGrid View 2. Ro [i] .cell [str]. Style. Back collar = color Olive; }}   

I have to reset the color according to the new value entered in DataGrade View 1. Here's my code.

  Private Zero Datagrams View1_CellEndEdit (Object Sender, DataGridViewCellEventArgs e) {if (e.ColumnIndex == 7 || e.ColumnIndex == 8 || e.ColumnIndex == 9 || e ColumnIndex == 10) {int prd_per_d = Convert toInt32 (DataGrid View1.CurrentRow.Cells [7]. Value); Int qty = Convert. ToInt32 (DataGrid View1.CurrentRow.Cells [6]. Value); DataGridView1.CurrentRow.Cells [8] .Value = qty / prd_per_d + 5; Date time sdt = convert ToDateTime (dataGridView1.CurrentRow.Cells [9]. Value); Int req_day = Convert. ToInt32 (DataGrid View1.CurrentRow.Cells [8]. Value); DataGridView1.CurrentRow.Cells [10] .Value = sdt.AddDays (req_day); Int cnt = dataGridView1.Rows.Count; For {i.e. i = 0; i & lt; cnt; i ++} {string start = datagroup view 1. Rao [i]. Sel [9]. Value Toasting (); String Start = Convert. Toddime (beginner toastring) Toasting ("DD MMM Yay"); String Finish = Data Grid View 1. Rao [i]. Sel [10]. Value ToString (); String endings = convert toDateTime (ending.ToString ()). ToString ("dd MMM yyyy"); Timespane TS = Convert. Broken time (ending toaster) - convert Tudetime (start tostring ()); Dual diff = ts, pause + 1; Int dif = Convert toInt32 (diff); For (int d = 0; d & lt; dif; d ++) {string str = Convert toDateTime (start.ToString ()). AddDays (D). Ostring ("dd MMM yyyy"); DataGrid View 2. Ro [i] .cell [str]. Style. Back collar = color Olive; }}}}   

But no change is usable when entering the value in DataAgrid View 1 It only works for the new cell, but does not change the current color cell to default is. Any ideas why?

I had the same problem a week ago. I solved it with only 2 rows of program code Hope this will help you! :

  this.dataGridView1.RowsDefaultCellStyle.BackColor = Color.Bisque; This.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -