cell color to change in data grid on mouse over 
Author Message
 cell color to change in data grid on mouse over

hi all
     This is an urgent requirement.Can you please tell me how can we change
the cell color in datagrid when is mouse is over that.

Thanks and regards,
Bhagavan vedavyas.A



Sat, 28 May 2005 13:16:34 GMT  
 cell color to change in data grid on mouse over
Hi Bhagavan,

A possible solution is to call HitTest when mouse moves. Get the cell bound
and move a textbox to the position. The code below from MSDN help of
DataGrid.GetCellBounds seems helpful:

protected void dataGrid1_MouseDown(object sender, MouseEventArgs e){
   // Use the HitTest method to get a HitTestInfo object.
   System.Windows.Forms.DataGrid.HitTestInfo hi;  
   DataGrid grid = (DataGrid) sender;
   hi=grid.HitTest(e.X, e.Y);
   // Test if the clicked area was a cell.
   if(hi.Type==DataGrid.HitTestType.Cell ) {
      // If it's a cell, get the GridTable and CurrencyManager of the
      // clicked table.        
      DataGridTableStyle dgt = dataGrid1.TableStyles[0];    
      CurrencyManager myCurrencyManager =
      (CurrencyManager)this.BindingContext
      [myDataSet.Tables[dataGrid1.DataMember]];
      // Get the Rectangle of the clicked cell.
      Rectangle cellRect;
      cellRect=grid.GetCellBounds(hi.Row, hi.Column);
      // Get the clicked DataGridTextBoxColumn.
      DataGridTextBoxColumn gridCol =
      (DataGridTextBoxColumn) dgt.[hi.Column];
      // Insert code to edit the value.

   }

Quote:
}

Hope this helps.

Best Regards,
Leo Chen

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

| Subject: cell color to change in data grid on mouse over
| Date: Tue, 10 Dec 2002 10:46:34 +0530
| Lines: 8
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

| Newsgroups: microsoft.public.dotnet.languages.CSharp
| NNTP-Posting-Host: 203.145.182.107
| Path: cpmsftngxa09!cpmsftngxa10!tkmsftngp01!TK2MSFTNGP11
| Xref: cpmsftngxa09 microsoft.public.dotnet.languages.csharp:115236
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| hi all
|      This is an urgent requirement.Can you please tell me how can we
change
| the cell color in datagrid when is mouse is over that.
|
| Thanks and regards,
| Bhagavan vedavyas.A
|
|
|



Sun, 29 May 2005 15:27:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Changing cell colors in a Grid Type Control

2. Changing text color of cells in the MS Grid control in C++

3. Changing text color of cells in the MS Grid control

4. Stingray objective grid-changing cells styles in browser grid

5. How to apply permisions on the data cells of the data grid

6. getting the bounds of the selected cell inside a data grid

7. Change cell colours in GRID.VBX?

8. Changing color of a X,Y cell with MSFlexGrid

9. Change cell color in CListCtrl

10. changing graphics mouse cursor color

11. combo box in a list or grid cell?

12. Objective Grid - forcing a cell to be uppercase???

 

 
Powered by phpBB® Forum Software