找回密码
 立即注册

QQ登录

只需一步,快速开始

zhengkun

版主

4

主题

10

帖子

532

积分

版主

Rank: 7Rank: 7Rank: 7

积分
532

活字格认证

最新发帖
zhengkun
版主   /  发表于:2014-1-17 16:50  /   查看:6562  /  回复:7
产品:FlexGrid for Win JPN
版本:4.6.20133.793
操作系统:win7 内核为日文

在Grid的KeyDownEdit事件中,用如下代码取出的String是乱码
Private Sub grid_KeyDownEdit(sender As Object, e As C1.Win.C1FlexGrid.KeyEditEventArgs) Handles grid.KeyDownEdit
       grid.Editor.GetType.ToString()
End Sub

谢谢!辛苦了

7 个回复

倒序浏览
zhengkun
版主   /  发表于:2014-1-17 16:58:00
沙发
忘了说了,编辑的列我设置了DataMap。设置方法如下:
Dim colDic As New Dictionary(Of String, String)
       colDic.Add("a", "A")
       colDic.Add("b", "B")
       colDic.Add("c", "C")
       colDic.Add("d", "D")
       colDic.Add("e", "E")
       grid.Cols(1).DataMap = colDic
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-1-17 17:44:00
板凳
回复 2楼zhengkun的帖子

zhengkun 你好,
感谢你的问题反馈。
由于 C1 控件源码是经过混淆处理的,所以在 GetType.ToString 时获取到不可读字符串。
可以通过判断 Editor 的基类来避免这个问题,测试代码如下:

  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             Dictionary<string, string> colDic = new Dictionary<string, string>();
  4.             colDic.Add("a", "A");
  5.             colDic.Add("b", "B");
  6.             colDic.Add("c", "C");
  7.             colDic.Add("d", "D");
  8.             colDic.Add("e", "E");
  9.             this.c1FlexGrid1.Cols[1].DataMap = colDic;

  10.             this.c1FlexGrid1.KeyDownEdit += c1FlexGrid1_KeyDownEdit;

  11.         }

  12.         void c1FlexGrid1_KeyDownEdit(object sender, C1.Win.C1FlexGrid.KeyEditEventArgs e)
  13.         {
  14.             if (this.c1FlexGrid1.Editor is ComboBox)
  15.             {
  16.                 MessageBox.Show("combo");
  17.             }
  18.         }
复制代码


如果有其他问题,欢迎继续提出,
谢谢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-1-20 09:28:00
地板
回复 2楼zhengkun的帖子

Hi zhengkun ,
请问问题解决了吗?使用了多少种编辑器呢,能否共享出你的代码?
回复 使用道具 举报
zhengkun
版主   /  发表于:2014-1-22 11:33:00
5#
十分感谢,问题已经解决。
就是使用判断基类来确定类型。
日期使用TypeOf (grid.Editor) Is Windows.Forms.DateTimePicker,
下拉菜单使用TypeOf (grid.Editor) Is Windows.Forms.ComboBox。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-1-22 12:25:00
6#
回复 5楼zhengkun的帖子


感谢你的反馈,有问题欢迎开新帖提问。
回复 使用道具 举报
wisdom
葡萄城公司职员   /  发表于:2014-2-27 16:21:00
7#
单纯判断grid.Editor的类型是不够的。
经调查,在leyser V8.5中C1FlexGrid(版本号为Version 2.6.20082.380)在使用default编辑器的情况下,
Cell数据类型
Editor的原始类型
C1FlexGrid .Editor.GetType.FullName的值
任意数字类型
TextBox
C1.Win.C1FlexGrid.p
string
TextBox
C1.Win.C1FlexGrid.ag
object
TextBox
C1.Win.C1FlexGrid.ag
任意类型
Combobox
C1.Win.C1FlexGrid.s
DateTime
DateTimePicker
C1.Win.C1FlexGrid.n
注:不管什么数据类型设置了Combobox后,取到的C1FlexGrid .Editor.GetType.FullName都是C1.Win.C1FlexGrid.s

因此If Me.Editor.GetType.FullName <> "C1.Win.C1FlexGrid.ag" Then的等价代码是
If not ( (TypeOf (Me.Editor) Is TextBox) AndAlso ((Me.Cols(e.Col).DataType = GetType(string)) or (Me.Cols(e.Col).DataType = GetType(object)))) Then

另外,如果C1FlexGrid .Editor被设置为自定义编辑器且类型为TextBox时,那么从语句的等价性上讲,if语句中还应该去除这种情况。

本帖子中包含更多资源

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

x
逝者已矣 来者可追
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-2-27 16:48:00
8#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部