DevExpress.XtraLayout.LayoutControl 动态添加控件
// Create an item within a specified group,
// bound to a specified data field with the specified editor
private LayoutControlItem CreateItemWithBoundEditor(BaseEdit editor, object dataSource,
string dataMember, LayoutControlGroup parentGroup) {
editor.DataBindings.Add("EditValue", dataSource, dataMember);
LayoutControlItem item = parentGroup.AddItem(dataMember, editor) as LayoutControlItem;
return item;
}
private void CreateLayout() {
//Add First Name and Last Name items
LayoutControlItem itemFirstName = CreateItemWithBoundEditor(new TextEdit(), employeesSource,
"FirstName", layoutControl1.Root);
LayoutControlItem itemLastName = CreateItemWithBoundEditor(new TextEdit(), employeesSource,
"LastName", layoutControl1.Root);
// Move the Last Name to the right of the First Name
itemLastName.Move(itemFirstName, InsertTypes.Right);
// Add the Birthday group with a birthday editor inside
LayoutControlGroup birthdayGroup = layoutControl1.AddGroup("Birthday Information");
CreateItemWithBoundEditor(new DateEdit(), employeesSource, "BirthDate", birthdayGroup);
// Add a tab with three address fields
TabbedControlGroup tabbedGroup = layoutControl1.AddTabbedGroup();
LayoutControlGroup addressGroup = tabbedGroup.AddTabPage("Address Details");
string[] dataFields = new string[] { "Country", "City", "Address" };
foreach (string dataField in dataFields)
CreateItemWithBoundEditor(new TextEdit(), employeesSource, dataField, addressGroup);
// Add a tab with a photo
LayoutControlGroup groupPhoto = tabbedGroup.AddTabPage("Photo");
CreateItemWithBoundEditor(new PictureEdit(), employeesSource, "Photo", groupPhoto);
}
再次添加的时候如果需要先清除之前的item,代码如下
layoutControlSelectBusiness.BeginUpdate();
layoutControlSelectBusiness.Controls.Clear();
layoutControlSelectBusiness.Root.Items.Clear();
再次添加item的代码
layoutControlSelectBusiness.EndUpdate();
谢谢你提供的这篇代码,帮我解决了layoutControl多列自动排版的问题, 关键代码:
// Move the Last Name to the right of the First Name
itemLastName.Move(itemFirstName, DevExpress.XtraLayout.Utils.InsertType.Right);
再次表示感谢!
DevExpress.XtraLayout.LayoutControl 动态添加控件的更多相关文章
- winform导入导出excel,后台动态添加控件
思路: 导入: 1,初始化一个OpenFileDialog类 (OpenFileDialog fileDialog = new OpenFileDialog();) 2, 获取用户选择文件的后缀名(s ...
- Android 在布局容器中动态添加控件
这里,通过一个小demo,就可以掌握在布局容器中动态添加控件,以动态添加Button控件为例,添加其他控件同样道理. 1.addView 添加控件到布局容器 2.removeView 在布局容器中删掉 ...
- VC中动态添加控件
VC中动态添加控件 动态控件是指在需要时由Create()创建的控件,这与预先在对话框中放置的控件是不同的. 一.创建动态控件: 为了对照,我们先来看一下静态控件的创建. 放置静态控件时必须先建立一个 ...
- jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法
博客分类: jquery-easyui jQueryAjax框架HTML 现象: AJAX返回的html无法做到自动渲染为EasyUI的样式.比如:class="easyui-layout ...
- asp.net动态添加控件学习
看了老师的教程后,自己一点感悟记录下来: 1.在页面提交后,动态生成的控件会丢失, 但如果生成控件的代码在pageload中,就可以,原理是每次生成页面都执行生成. 2.动态按件或页面原来控件, 在页 ...
- WPF:理解ContentControl——动态添加控件和查找控件
WPF:理解ContentControl--动态添加控件和查找控件 我认为WPF的核心改变之一就是控件模型发生了重要的变化,大的方面说,现在窗口中的控件(大部分)都没有独立的Hwnd了.而且控件可以通 ...
- 怎样在不对控件类型进行硬编码的情况下在 C#vs 中动态添加控件
文章ID: 815780 最近更新: 2004-1-12 这篇文章中的信息适用于: Microsoft Visual C# .NET 2003 标准版 Microsoft Visual C# .NET ...
- JQuery动态添加控件并取值
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- WPF 动态添加控件以及样式字典的引用(Style introduction)
原文:WPF 动态添加控件以及样式字典的引用(Style introduction) 我们想要达到的结果是,绑定多个Checkbox然后我们还可以获取它是否被选中,其实很简单,我们只要找到那几个关键的 ...
随机推荐
- MVC对集合筛选,不使用Where(),而使用FindAll()
当想对集合筛选的时候,经常想到用Where过滤,而实际上List<T>.FindAll()也是不错的选择. 如果有一个订单,属性有下单时间.区域等等.如何使用List<T>.F ...
- .NET:异常以及异常处理框架探析(转载)
概述 一般情况下,企业级应用都对应着复杂的业务逻辑,为了保证系统的健壮,必然需要面对各种系统业务异常和运行时异常. 不好的异常处理方式容易造成应用程序逻辑混乱,脆弱而难于管理.应用程序中充斥着零散的异 ...
- pom-4.0.0.xml中心仓库
<!--Licensed to the Apache Software Foundation (ASF) under oneor more contributor license agreeme ...
- 定义和使用EL函数
EL为表达式语言,在EL中,允许定义和使用函数.下面将介绍如何定义和使用EL的函数. 1. 定义和使用函数 函数的定义和使用分为以下3个步骤: (1)编写一个Java类,并在该类中编写公用的静态方法, ...
- iOS:UIButton按钮的详解
UIButton的详细介绍: 一.按钮具有的属性: @property(nonatomic,readonly) UIButtonType buttonType; //按钮形状类型 @property ...
- C++代码统计工具
自己前几天写的C++代码统计工具. http://pan.baidu.com/s/17SnnH
- 转】未指定 INSTANCESHAREDWOWDIR 命令行值。如果指定INSTANCESHAREDDIR 值,则必须指定该值 .
插入光盘后不要用autorun的安装,使用命令行安装!cd进安装光盘的根目录,输入命令:setup.exe /INSTALLSHAREDDIR="D://Program Files//Mic ...
- libFM 简介
原文:https://eachcloudcn.blob.core.chinacloudapi.cn/clips/XOI1W.htm libFM全称为Factorization Machine Libr ...
- 给MySQL中某表增加一个新字段,设为主键值为自动增长。
alter table test_tb add ID int(10) primary key AUTO_INCREMENT; 设定完成后,原有记录的该字段会增加并自动设上值.以后的值会在已有记录的最 ...
- Inception in CNN
之前也写过GoogLeNet的笔记.但那个时候对Inception有些似懂非懂,这周又一次看了一遍,觉得有了新的体会,特地又一次写一篇博客与它再续前缘. 本文属于论文笔记性质.特此声明. Networ ...