找回密码
 立即注册

QQ登录

只需一步,快速开始

青春不再

初级会员

11

主题

30

帖子

295

积分

初级会员

积分
295
青春不再
初级会员   /  发表于:2017-6-21 16:46  /   查看:3274  /  回复:1
已经设定某一列单元格为leftcenter   然后 怎莫设置 这一列的某一个单元格  rightcenter 。
    Public Function CellRange(ByVal maxRows As Integer) As Boolean
        sprDetailedSchedule.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom
        Dim rng As CellRange = sprDetailedSchedule.GetCellRange(maxRows, 2, maxRows, 4)
        rng.Style = sprDetailedSchedule.Styles("FirstCustomStyle")
        rng.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.LeftCenter
        sprDetailedSchedule.MergedRanges.Add(rng)


        Dim omg As CellRange = sprDetailedSchedule.GetCellRange(maxRows, 5, maxRows, 7)
        omg.Style = sprDetailedSchedule.Styles("FirstCustomStyle")
        omg.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.RightCenter
        sprDetailedSchedule.MergedRanges.Add(omg)

    End Function



sprDetailedSchedule   为我的表格名称。

1 个回复

倒序浏览
JeffryLI
葡萄城公司职员   /  发表于:2017-6-21 17:38:13
沙发
您好,这个可以换种方式实现,因为在列上设置是针对整列的,我们可以在C1GridView1_RowDataBound,中对特定单元格来设置TextAlign
  1. protected void C1GridView1_RowDataBound(object sender, C1GridViewRowEventArgs e)
  2.                 {
  3.                         for (int i = 0; i < e.Row.Cells.Count; i++)//获取总列数   
  4.                         {
  5.                                 //如果是数据行则添加title   
  6.                                 if (e.Row.RowType == C1GridViewRowType.DataRow)
  7.                                 {//设置title为gridview的head的text   
  8.                                         e.Row.Cells[i].Attributes.Add("title", "提示信息如下:"+"\n"+C1GridView1.HeaderRow.Cells[i].Text.ToString().Trim() + ":"+ e.Row.Cells[i].Text.ToString().Trim());
  9.                                         if (e.Row.Cells[i].Text == "22")//针对单元格为22的设置居中
  10.                                         {
  11.                                                 e.Row.Cells[i].Attributes.Add("style", "text-align: center");
  12.                                         }

  13.                                 }
  14.                         }
  15.                 }
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
请点击评分,对我5分评价,谢谢!

葡萄城控件服务团队
官方网站: https://www.grapecity.com.cn/developer
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部