对左右两个单元格设置DataMap,左边是Dictionary<string, string>,右边是Dictionary<int, string>
- void PopupQuery_Load(object sender, EventArgs e)
- {
- Dictionary<string, string> dic_string;
- dic_string.Add("1", "值1");
- dic_string.Add("2", "值2");
- Dictionary<int, string> dic_int;
- dic_int.Add(1, "值1");
- dic_int.Add(2, "值2");
- CellStyle cs1 = c1FlexGridQuery.Styles.Add("Combo1");
- cs1 .DataType = typeof(string);
- cs1 .DataMap = dic_string;
- CellStyle cs2 = c1FlexGridQuery.Styles.Add("Combo2");
- cs2 .DataType = typeof(string);
- cs2 .DataMap = dic_int;
- c1FlexGridQuery.SetCellStyle(1,1, cs1 );
- c1FlexGridQuery.SetCellStyle(1,2, cs2 );
- }
复制代码
在分别在两个单元格中选择下拉项目,
譬如我在左单元格选择了 “值1”,c1Label1调用GetDataDisplay并传值显示“值1”(TValue ),在右单元格选择了 “值2”,c1Label12调用GetDataDisplay并传值显示 2(TKey),而不是 “值2”(TValue) 。
- private void c1FlexGridQuery_CellChanged(object sender, RowColEventArgs e)
- {
- c1Label1.Value = c1FlexGridQuery.GetDataDisplay(1, 1);
- c1Label2.Value = c1FlexGridQuery.GetDataDisplay(1, 2);
- }
复制代码
为什么单元格DataMap在接受Dictionary<string,string>后,GetDataDisplay()方法显示的是TValue,
而在接受时Dictionary<int,string>后,GetDataDisplay()方法显示的是TKey ? |
|