鼠标移到datagrid某行的某列时显示该列内容,我用的是第三方控件中的datagrid

解决方案 »

  1.   

    呀的,你用的是第三方datagrid到底是什么嘛,不说出来谁能帮你
      

  2.   

    public class DataGridCellTips : DataGrid 
     

     
         private int hitRow; 
     
         private int hitCol; 
     
         private System.Windows.Forms.ToolTip toolTip1; 
      
         public DataGridCellTips() 
     
         { 
     
              hitRow = -1; 
     
              hitCol = -1; 
     
              this.toolTip1 = new System.Windows.Forms.ToolTip(); 
     
              this.toolTip1.InitialDelay = 200; 
     
              this.MouseMove += new MouseEventHandler(HandleMouseMove); 
     
         } 
      
         private void HandleMouseMove(object sender, MouseEventArgs e) 
     
         { 
     
              DataGrid.HitTestInfo hti = this.HitTest(new Point(e.X, e.Y)); 
     
              if(hti.Type == DataGrid.HitTestType.Cell 
     
                   && ( hti.Row != hitRow || hti.Column != hitCol) ) 
     
              {     //new hit row 
     
                   hitRow = hti.Row; 
     
                   hitCol = hti.Column; 
     
                   if(this.toolTip1 != null && this.toolTip1.Active) 
     
                        this.toolTip1.Active = false; //turn it off 
     
                   this.toolTip1.SetToolTip(this, this[hitRow, hitCol].ToString()); 
     
                   this.toolTip1.Active = true; //make it active so it can show itself 
     
                   //Console.WriteLine("MouseMove "+ hitRow.ToString() + " " + hitCol.ToString()); 
     
              } 
     
         } 
     

     
      

  3.   

    我用的是ComponentArt datagrid这个控件
      

  4.   

    谢谢你啊,实现不了。我刚才忘说了,我是做web
      

  5.   

    在ItemDataBound事件里面
    e.Item.Cells[0].Attributes.Add("title", "提示的内容");
      

  6.   

    我用的控件里面没有e.Item.Cells[0].Attributes.Add()这个阿