【问题标题】:Change GridRowStyle in Telerik WinForm在 Telerik WinForm 中更改 GridRowStyle
【发布时间】:2011-05-10 07:01:44
【问题描述】:

我的数据库中有一个字段用于检测一行的字体样式。 字体样式是常规的,这是真的。 我想在选择它时更改我的行样式。我写这个:

private void myGrid_SelectionChanged(object sender, EventArgs e) 
{ 
DataBaseComponent.EditFieldofObject(object1.Serial, true);
if (myGrid.SelectedRows[0].VisualElement != null) 
    myGrid.SelectedRows[0].VisualElement.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(178))); 
myGrid.SelectedRows[0].Cells["myField"].Value = true;
}

但它不起作用,我必须再次绑定网格才能看到此更改。

【问题讨论】:

    标签: winforms coding-style grid telerik


    【解决方案1】:

    为什么不使用 ItemDataBound 而不是 SelectionChanged?这将满足您的需求。

        protected void myGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataBoundItem = (GridDataItem)e.Item;
                if (dataBoundItem["ColumnName"].Text.ToString() == "True")
                {
                    // Do something here
                }
            }
        }
    

    Telerik 上有一个很好的 article 解释它。

    【讨论】:

      猜你喜欢
      • 2011-10-04
      • 2011-03-07
      • 1970-01-01
      • 1970-01-01
      • 2011-01-13
      • 2019-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多