Smobiler上海石磨_.NET移动开发平台
标题:
自定义控件items集合类型问题
[打印本页]
作者:
boyhome
时间:
2021-11-3 18:16
标题:
自定义控件items集合类型问题
using Smobiler.Core;
using Smobiler.Core.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace myapp
{
////ToolboxItem用于控制是否添加自定义控件到工具箱,true添加,false不添加
[System.ComponentModel.ToolboxItem(true)]
partial class fontview : Smobiler.Core.Controls.MobileUserControl
{
private List<fontviewGroup> group = new List<fontviewGroup>();
[Category("自定义"), Description("数据集")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), MergableProperty(false)]
[TypeConverter(typeof(System.ComponentModel.CollectionConverter))]
[Editor(typeof(System.ComponentModel.Design.CollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public List<fontviewGroup> Groups
{
get { return group; }
set { group = value;}/*此处set没有执行*/
}
//[Serializable]
public class fontviewGroup
{
[Description("数量"), Browsable(true)]
public int shl { get; set; }
[Description("事件名"), Browsable(true)]
private string name = "";
public string Name {
get {return name; }
set { name = value; }
}
[Description("字体大小"), Browsable(true)]
public int fontsize { get; set; }
[Description("字体颜色"), Browsable(true)]
public string fontcolor { get; set; }
}
public fontview() : base()
{
//This call is required by the SmobilerUserControl.
InitializeComponent();
Mycontrol(Groups);
}
public void Mycontrol(List<fontviewGroup> data)
{
Toast("input");
foreach(fontviewGroup v in data)
{
Toast(v.Name);
}
}
}
}
复制代码
这是我控件里的定义属性,如何获得控件属性框groups集合的值呢?修改了没有反应
作者:
fox12300
时间:
2021-12-1 13:49
解决了吗?我当时也遇到过,记得看过一个贴子,说构造函数和页面LOAD()是有执行顺序的(大概这个意思吧,不准确),如果没解决,你试试把 Mycontrol(Groups);这一行移动到 XXX_load中试试
作者:
boyhome
时间:
2021-12-2 07:24
fox12300 发表于 2021-12-1 13:49
解决了吗?我当时也遇到过,记得看过一个贴子,说构造函数和页面LOAD()是有执行顺序的(大概这个意思吧, ...
谢谢,后来用代码传值了,反正也是动态,属性框赋值只是测试一下,发现无效觉得很奇怪。谢谢回复,有时间我再测试一下你说的。
欢迎光临 Smobiler上海石磨_.NET移动开发平台 (https://www.smobiler.com/)
Powered by Discuz! X3.2