sathish kumar

sathish kumar

  • NA
  • 13
  • 9.2k

How to Get Grid Color in C#

Dec 12 2013 11:57 AM
Hi all....
 
I doing Emp_attendance works in C#(Windows Application), in that grid view i am using many column colors in depend on condition. the following grid sample is simplified my question...
 
-----------------------------------------------------
empname   |  1   | 2   | 3 | 4 | 5 |.....|11|...|30or 31(in depend on month)
----------------------------------------------------
  xxx     |  P   | P   | P |   | P |.....|  |.....
  ddd     |  P   | P   | A |   | A |.....|  |.....
  rrr     |  A   | A   | P |   | A |.....|  |.....
----------------------------------------------------
 

1)In this grid view the Column Header 1 to 31 is days in month
2)P=Present , A=Absent.
3)See the Grid view column 4 & 11 that column Back color is gray. Because 4th & 11th is Sunday so the employee attendance is not fill.
4)This case is not take the gridview column index because in this gridview column count is changed depend on month(Ex--Jan(31)Feb(28or29)Apr(30)), So the column index is not taking for this case...
 
I want the mouse enter that particular 4th & 11th column the tooltip is display the message "The Day is Sunday"
 
i try to many way but not use, my try code is below...
private void GridView_MouseHover(object sender, EventArgs e)
        {
           // Color gridcolor = GridView.CurrentCell.Style.BackColor;
          //  GridView.CurrentCell.Style.BackColor = Color.Gray;
           // GridView.DefaultCellStyle.BackColor = Color.Gray;
         //  MessageBox.Show(gridcolor.ToString());
               if (GridView.CurrentCell.Style.BackColor == Color.Gray)
           {
               GridView.CurrentCell.ToolTipText = "Sunday";
           }
        }
 

please help me...

Answers (1)