只能使用datagrid的mousedow事件
如: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.GridColumnStyles[hi.Column];
      // Insert code to edit the value.
      
   }

解决方案 »

  1.   

    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    int columns = DataGrid1.Columns.Count;
    if(e.Item.ItemIndex >= 0)
    {
    for(int i=0;i<DataGrid1.Columns.Count;i++)
    {
    e.Item.Cells[i].Attributes.Add("onmouserdown","javascript:wondow.close()");
    }
    }
    }
      

  2.   

    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {

    if (e.Item.ItemIndex >= 0)
    {
    e.Item.Attributes["onMouseOver"] = "javascript:this.bgColor='#C6D7E7';";
    e.Item.Attributes["onMouseOut"] = "javascript:this.bgColor='#ffffff';";

    }
      

  3.   

    楼上的兄弟,不行,我是说在鼠标进入以后,在cell编辑框中,以后datagrid就不会触发键盘和鼠标的事件了,点击鼠标右键就会出现一般windows中的右键菜单。是“复制、粘贴”等菜单项。
      

  4.   

    那是因为响应右键的控件是TextBox,右键菜单出现的菜单项与TextBox是一样的。假设你给DataGrid添加了DataGridTableStyle,你可以这样做
    DataGrid dg;
    ...
    ((DataGridTextBoxColumn)dg.TableStyles[0].GridColumnStyles["..."]).TextBox.MouseDown+=new MouseEventHandler(abc);
    private void abc(object sender,MouseEventArgs e)
    {
    ...
    }
    响应键盘一样的道理,请参照:http://www.csdn.net/Develop/read_article.asp?id=15109
      

  5.   

    可能是这个样子!不知道此处textbox与控件textbox有何不同!此处的没有password属性其他的呢?
      

  6.   

    没什么区别吧,我看那与将TextBox作为DataGrid的子控件没有区别