找回密码
 立即注册

QQ登录

只需一步,快速开始

笨小孩

注册会员

8

主题

19

帖子

113

积分

注册会员

积分
113
笨小孩
注册会员   /  发表于:2022-5-19 18:11  /   查看:1566  /  回复:5
本帖最后由 笨小孩 于 2022-6-6 10:41 编辑

C1Flexgrid  某一列,其中不同行设置不同控件,  有的单元中是下拉框,有的就是label

5 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-19 18:13:58
沙发
开发包自带的示例中就有一个


本帖子中包含更多资源

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

x
回复 使用道具 举报
笨小孩
注册会员   /  发表于:2022-5-19 18:36:56
板凳
Richard.Ma 发表于 2022-5-19 18:13
开发包自带的示例中就有一个

能帮忙把代码文件贴出来吗,我这里没开发包。  在Dom中没找到。 最近刚接触这个控件。 谢谢!  
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-20 09:20:40
地板
代码较多,只能贴出一部分,实际上就是设置Editor属性


  1. //---------------------------------------------------------------------------------
  2.                         // ** show built-in editors

  3.                         CellStyle cs = _flex.Styles.Add("Built-In Editors");
  4.                         cs.UserData =
  5.                                 @"\b ** Built-In Editors\b0\par " +
  6.                                 @"These cells use the C1FlexGrid built-in editors, controlled by " +
  7.                                 @"the setting of the DataType, DataMap, ComboList, and EditMask properties.";

  8.                         // add boolean row (with checkbox)
  9.                         _flex.Rows.Count = 1;
  10.                         Row r = _flex.Rows.Add();
  11.                         r.Caption  = "CheckBox";
  12.                         r.DataType = typeof(bool);
  13.                         r.Style.MergeWith(cs);

  14.                         // add boolean row (text mapped)
  15.                         r = _flex.Rows.Add();
  16.                         r.Caption  = "ToggleText";
  17.                         r.DataType = typeof(bool);
  18.                         r.Format   = "Yes;No";
  19.                         r.TextAlign= TextAlignEnum.CenterCenter;
  20.                         r.Style.MergeWith(cs);

  21.                         // add popup row
  22.                         r = _flex.Rows.Add();
  23.                         r.Caption  = "Popup";
  24.                         r.ComboList= "...";
  25.                         r.Style.MergeWith(cs);

  26.                         // add editable popup row
  27.                         r = _flex.Rows.Add();
  28.                         r.Caption  = "PopEdit";
  29.                         r.ComboList= "|...";
  30.                         r.Style.MergeWith(cs);

  31.                         var c= _flex.Cols[2];
  32.                        
  33.                         c.ComboList = "|...";
  34.                         c.Style.MergeWith(cs);

  35.                         // add row with masked textbox
  36.                         r = _flex.Rows.Add();
  37.                         r.Caption  = "TextBox";
  38.                         r.EditMask = "(999) 999-9999";
  39.                         r.Style.MergeWith(cs);

  40.                         // add row with simple list
  41.                         r = _flex.Rows.Add();
  42.                         r.Caption  = "List";
  43.                         r.ComboList= comboList;
  44.                         r.Style.WordWrap = true;
  45.                         r.Style.MergeWith(cs);

  46.                         // add row with combo list
  47.                         r = _flex.Rows.Add();
  48.                         r.Caption  = "Combo";
  49.                         r.ComboList= "|" + comboList;
  50.                         r.TextAlign= TextAlignEnum.CenterCenter;
  51.                         r.Style.MergeWith(cs);

  52.                         // add row with date time picker
  53.                         r = _flex.Rows.Add();
  54.                         r.Caption  = "DateTime";
  55.                         r.DataType = typeof(DateTime);
  56.                         r.Style.MergeWith(cs);

  57.                         // add row with time picker
  58.                         r = _flex.Rows.Add();
  59.                         r.Caption  = "Time";
  60.                         r.DataType = typeof(DateTime);
  61.                         r.Format   = "HH:mm";
  62.                         r.Style.MergeWith(cs);

  63.                         // add row with data/image maps
  64.                         r = _flex.Rows.Add();
  65.                         r.Caption  = "Data/ImageMaps";
  66.                         r.DataType = typeof(int);
  67.                         r.ImageMap = imgMap;
  68.                         r.DataMap  = dataMap;
  69.                         r.TextAlign= TextAlignEnum.LeftCenter;
  70.                         r.Style.MergeWith(cs);

  71.                         //---------------------------------------------------------------------------------
  72.                         // ** show regular controls used as editors

  73.                         cs = _flex.Styles.Add("Regular Controls");
  74.                         cs.BackColor = Color.Linen;
  75.                         cs.UserData =
  76.                                 @"\b ** Regular Controls\b0\par " +
  77.                                 @"These cells use regular .NET controls as grid editors. The controls were added " +
  78.                                 @"to the form at design time and assigned to grid rows. Their functionality is somewhat " +
  79.                                 @"limited because they don't implement the IC1EmbeddedEditor interface.";

  80.                         // add row with custom editor (TextBox)
  81.                         r = _flex.Rows.Add();
  82.                         r.Caption  = "TextBox";
  83.                         r.Editor   = textBox1;
  84.                         r.Style.MergeWith(cs);

  85.                         // add row with custom editor (Combo)
  86.                         r = _flex.Rows.Add();
  87.                         r.Caption  = "ComboBox";
  88.                         r.DataType = typeof(string);
  89.                         r.Editor   = comboBox1;
  90.                         r.Style.MergeWith(cs);

  91.                         // add row with custom editor (DomainUpDown)
  92.                         r = _flex.Rows.Add();
  93.                         r.Caption  = "DomainUpDown";
  94.                         r.DataType = typeof(string);
  95.                         r.Editor   = domainUpDown1;
  96.                         r.Style.MergeWith(cs);

  97.                         // add row with custom editor (NumericUpDown)
  98.                         r = _flex.Rows.Add();
  99.                         r.Caption  = "NumericUpDown";
  100.                         r.DataType = typeof(double);
  101.                         r.Editor   = numericUpDown1;
  102.                         r.Style.MergeWith(cs);

  103.                         //---------------------------------------------------------------------------------
  104.                         // ** show custom editors based on regular controls

  105.                         cs = _flex.Styles.Add("Custom Controls");
  106.                         cs.BackColor = Color.LightGoldenrodYellow;
  107.                         cs.UserData =
  108.                                 @"\b ** Custom Controls\b0\par " +
  109.                                 @"These cells use custom controls that inherit from the base .NET controls " +
  110.                                 @"and implement methods in the IC1EmbeddedEditor interface. Because the grid " +
  111.                                 @"binds using reflection, you don't have to implement the entire interface, only " +
  112.                                 @"the methods that are relevant to your specific control.";

  113.                         // add row with custom editor (Numeric, integer, positive, no calculator)
  114.                         r = _flex.Rows.Add();
  115.                         r.Caption  = "Positive Integer";
  116.                         r.DataType = typeof(int);
  117.                         r.Format   = "#,###";
  118.                         r.Editor   = new NumericTextBox(r.Format, false);
  119.                         ((NumericTextBox)r.Editor).Minimum = 0;
  120.                         r.Style.MergeWith(cs);

  121.                         // add row with custom editor (Numeric, three decimals, no calculator)
  122.                         r = _flex.Rows.Add();
  123.                         r.Caption  = "Double";
  124.                         r.DataType = typeof(double);
  125.                         r.Format   = "#,###.000";
  126.                         r.Editor   = new NumericTextBox(r.Format, false);
  127.                         r.Style.MergeWith(cs);

  128.                         // add row with custom editor (Numeric, two decimals, calculator)
  129.                         r = _flex.Rows.Add();
  130.                         r.Caption  = "Calculator";
  131.                         r.DataType = typeof(double);
  132.                         r.Format   = "#,###.000";
  133.                         r.Editor   = new NumericTextBox(r.Format, true);
  134.                         r.Style.MergeWith(cs);
复制代码
回复 使用道具 举报
笨小孩
注册会员   /  发表于:2022-5-20 10:10:50
5#
Richard.Ma 发表于 2022-5-20 09:20
代码较多,只能贴出一部分,实际上就是设置Editor属性

嗯,谢谢啦
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2022-5-20 12:31:39
6#
不客气
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部