2014-01-30 16 views
0

我有一個Syncfusion的GridGroupingControl在Syncfusion的GridGroupingControl中格式化一列

我嘗試以自定義格式格式化一列。

我的列值與「000123」類似,我想將其顯示爲「123」(刪除前導零,或者相同,只顯示前三個與十進制格式「D3」相對應的字符)

我嘗試下面的代碼不起作用:

private void ggcResult_DataSourceChanged(object sender, EventArgs e) 
{ 
    if (ggcResult.TableDescriptor.Columns.Contains("MY_COL")) 
    { 
     var col = ggcResult.TableDescriptor.Columns["MY_COL"]; 
     col.Appearance.AnyCell.Format = "D3"; 
    } 
} 

或者是太晚或太早,反正欄顯示像「000123」 ......

回答

0

我發現解決方案ot我的問題... 這是在格式列數據...被認爲是「字符串」,但「字符串」不能像「D7」格式的「int」格式化。

因此,解決辦法是改變這種格式:

private void ggcResult_DataSourceChanged(object sender, EventArgs e) 
{ 
    if (ggcResult.TableDescriptor.Columns.Contains("MY_COL")) 
    { 
     var col = ggcResult.TableDescriptor.Columns["MY_COL"]; 
     // setting the type for corresponding format -------------- 
     col.Appearance.AnyCell.CellValueType = typeof(int); 
     col.Appearance.AnyCell.Format = "D3"; 
    } 
}