dbtreeview怎么带checkbox delphi 第 1 页
1个回答
推荐于2016-05-21 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517183
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
在web开发中,带checkbox的tree是一个很有用的东东,比如权限选择、分类管理,如果不用sl,单纯用js+css实现是很复杂的,有了SL之后,就变得很轻松了
解决方案一:
利用Silvelright ToolKit(微软的开源项目),
解决方案二:
telerik公司的Rad for Silverlight商业控件
不管用哪一种方案,代码都是差不多的,为了实现数据绑定,先创建一个silverlight类库项目BusinessObject,定义数据项实体:
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Markup;
namespace BusinessObject
{
/// <summary>
/// 地区数据项
/// </summary>
[ContentProperty("Children")]//指示Children属性是 XAML 的Content内容属性
public class PlaceItem : INotifyPropertyChanged
{
/// <summary>
/// 构造函数
/// </summary>
public PlaceItem()
{
Children = new Collection<PlaceItem>();
IsSelected = true;
}
/// <summary>
/// 地区名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 地区描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 得到下级元素容器
/// </summary>
public Collection<PlaceItem> Children { get; private set; }
/// <summary>
/// 是否有子项
/// </summary>
public bool HasChild
{
get
{
return Children.Count > 0;
}
}
/// <summary>
/// 是否选中
/// </summary>
private bool? _isSelected;
/// <summary>
/// 该特性是否想要被安装
/// </summary>
public bool? IsSelected
{
get
{
return _isSelected;
}
set
{
if (value != _isSelected)
{
_isSelected = value;
OnPropertyChanged("IsSelected");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 属性改变时触发事件
/// </summary>
/// <param name="propertyName">Property that changed.</param>
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
然后再定义一个 演示数据集合类:
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Markup;
namespace BusinessObject
{
/// <summary>
/// 地区数据项
/// </summary>
[ContentProperty("Children")]//指示Children属性是 XAML 的Content内容属性
public class PlaceItem : INotifyPropertyChanged
{
/// <summary>
/// 构造函数
/// </summary>
public PlaceItem()
{
Children = new Collection<PlaceItem>();
IsSelected = true;
}
/// <summary>
/// 地区名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 地区描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 得到下级元素容器
/// </summary>
public Collection<PlaceItem> Children { get; private set; }
/// <summary>
/// 是否有子项
/// </summary>
public bool HasChild
{
get
{
return Children.Count > 0;
}
}
/// <summary>
/// 是否选中
/// </summary>
private bool? _isSelected;
/// <summary>
/// 该特性是否想要被安装
/// </summary>
public bool? IsSelected
{
get
{
return _isSelected;
}
set
{
if (value != _isSelected)
{
_isSelected = value;
OnPropertyChanged("IsSelected");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 属性改变时触发事件
/// </summary>
/// <param name="propertyName">Property that changed.</param>
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
解决方案一:
利用Silvelright ToolKit(微软的开源项目),
解决方案二:
telerik公司的Rad for Silverlight商业控件
不管用哪一种方案,代码都是差不多的,为了实现数据绑定,先创建一个silverlight类库项目BusinessObject,定义数据项实体:
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Markup;
namespace BusinessObject
{
/// <summary>
/// 地区数据项
/// </summary>
[ContentProperty("Children")]//指示Children属性是 XAML 的Content内容属性
public class PlaceItem : INotifyPropertyChanged
{
/// <summary>
/// 构造函数
/// </summary>
public PlaceItem()
{
Children = new Collection<PlaceItem>();
IsSelected = true;
}
/// <summary>
/// 地区名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 地区描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 得到下级元素容器
/// </summary>
public Collection<PlaceItem> Children { get; private set; }
/// <summary>
/// 是否有子项
/// </summary>
public bool HasChild
{
get
{
return Children.Count > 0;
}
}
/// <summary>
/// 是否选中
/// </summary>
private bool? _isSelected;
/// <summary>
/// 该特性是否想要被安装
/// </summary>
public bool? IsSelected
{
get
{
return _isSelected;
}
set
{
if (value != _isSelected)
{
_isSelected = value;
OnPropertyChanged("IsSelected");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 属性改变时触发事件
/// </summary>
/// <param name="propertyName">Property that changed.</param>
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
然后再定义一个 演示数据集合类:
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Markup;
namespace BusinessObject
{
/// <summary>
/// 地区数据项
/// </summary>
[ContentProperty("Children")]//指示Children属性是 XAML 的Content内容属性
public class PlaceItem : INotifyPropertyChanged
{
/// <summary>
/// 构造函数
/// </summary>
public PlaceItem()
{
Children = new Collection<PlaceItem>();
IsSelected = true;
}
/// <summary>
/// 地区名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 地区描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 得到下级元素容器
/// </summary>
public Collection<PlaceItem> Children { get; private set; }
/// <summary>
/// 是否有子项
/// </summary>
public bool HasChild
{
get
{
return Children.Count > 0;
}
}
/// <summary>
/// 是否选中
/// </summary>
private bool? _isSelected;
/// <summary>
/// 该特性是否想要被安装
/// </summary>
public bool? IsSelected
{
get
{
return _isSelected;
}
set
{
if (value != _isSelected)
{
_isSelected = value;
OnPropertyChanged("IsSelected");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 属性改变时触发事件
/// </summary>
/// <param name="propertyName">Property that changed.</param>
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询