获取选中的当前行的序号:e.Item.ItemIndex

解决方案 »

  1.   

    背景色
    private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemIndex!=-1)
    {
    e.Item.Attributes.Add("onmouseover","this.setAttribute('BKC',this.style.backgroundColor);this.style.backgroundColor='#999999';this.style.cursor='hand';");
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=this.getAttribute('BKC');");
    }
      

  2.   

    当前行的背景色:e.Item.BackColor="";
      

  3.   

    e后面怎么下拉不出item啊????????????
      

  4.   

    DataGrid1.Items[DataGrid1.SelectedIndex].BackColor=“”;
      

  5.   

    写在dataGrid的单击事件中,行吗?
      

  6.   

    dataGrid的单击事件?单击事件好像是SelectedIndexChanged吧?
      

  7.   

    dataGrid 有selectedindexchanged 吗??/怎么找不到????
      

  8.   

    selectedindexchanged事件你只要双击dataGrid 就能出来
    但我现在还不知道你要实现怎样的功能,能说详细点吗
      

  9.   

    第一个我想实现选定一行,该行的背景色变化.第二个,在dataGrid 中有一选择项内容,即,(checkBox类型),通过打勾选择,我要知道我选择了哪些行??
      

  10.   

    双击出来的是这个事件啊!!
    private void dataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
    {

    }
      

  11.   

    第一个问题你可以按照csl610(流浪者)的去做
    第二个问题:for(int i=0;i<this.DataGrid1.Items.Count;i++)
    {
    if(((CheckBox)this.DataGrid1.Items[i].FindControl("CheckBox1")).Checked = true)
                                      {
                                         return true; //表示这行已经选中
                                      }
    }
      

  12.   

    晕  你是winform的啊   我还一直以为是WEB窗体呢
      

  13.   

    对,是winform,呵呵!谢谢!!!我试试看,好吗?
      

  14.   

    我的dataGrid1,就是下拉不出Items,怎么回事啊?????????
      

  15.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=00C78024-5C08-4F3F-BCA8-AB3C0B330A12
      

  16.   

    dataGrid1.SelectionBackColor属性可以改变选定行的背景颜色。。
      

  17.   

    获取选中的当前行的序号
    int index=this.DataGrid1.SelectedIndex;
      

  18.   

    http://blog.csdn.net/zhzuo/archive/2004/09/10/100882.aspx
      

  19.   

    private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    System.Drawing.Point pt = new Point(e.X, e.Y);  
    DataGrid.HitTestInfo hti = this.DGwlInfo.HitTest(pt); 
    WLkpRow=hti.Row;
    DataGrid1.Select(hti.Row);//置这一行为选定行 DGCModify(hti);
    }
    这样当前行就会被选定
    然后再用
    dataGrid1.SelectionBackColor
    设置选定行得背景色就可以了
      

  20.   

    WinForm下的DataGrid访问单元格的数据:
    DataGrid dataGrid = ......;
    // 比如要访问第1行第1列的数据:
    dataGrid[1,1].ToString();
    ......
    你可以做个循环访问一整列。
      

  21.   

    获得当前行:dataGrid1.CurrentRowIndex