【问题标题】:Changing the style of Individual cells in a datagridview row更改 datagridview 行中单个单元格的样式
【发布时间】:2010-10-15 22:04:47
【问题描述】:

是否可以为数据网格视图行中的各个单元格赋予不同的样式,例如背景颜色、字体颜色等?

我不是说给整行一个新的样式,只是一个特定的单元格。

【问题讨论】:

    标签: vb.net datagrid datagridview windows-forms-designer


    【解决方案1】:

    当然:

    Me.myDatagridview.Rows(0).Cells(0).Style.ForeColor = Color.Aqua

    【讨论】:

      【解决方案2】:

      这样的?

      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
      {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string imageName = e.Row.Cells[0].Text.ToString();
            e.Row.Cells[1].Attributes.Add(“Style”,
              “background-image: url(’images/” + imageName + “‘);”);    
        }
      }
      

      【讨论】:

      • post 被标记为 windows forms, vb.net
      猜你喜欢
      • 2011-07-03
      • 2012-08-04
      • 2011-12-25
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 2020-12-06
      • 1970-01-01
      相关资源
      最近更新 更多