自动生成LayoutControl后,界面总是不对:
在LayoutControl中找到一个BestFit()方法,调用后神奇的结果出现了,这不正是我想要的吗?
测试代码:
public partial class TEST2 : Form
{
public TEST2()
{
InitializeComponent();
} private void TEST2_Load(object sender, EventArgs e)
{
layoutControl1.Root.Clear(); LayoutControlItem billDateItem = new LayoutControlItem();
billDateItem.Control = new TextEdit();
billDateItem.Text = "日期";
billDateItem.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
layoutControl1.Root.AddItem(billDateItem); LayoutControlItem billCodeItem = new LayoutControlItem();
billCodeItem.Control = new TextEdit();
billCodeItem.Text = "单号";
billCodeItem.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
layoutControl1.Root.AddItem(billCodeItem, billDateItem, InsertType.Right); LayoutControlItem billStateItem = new LayoutControlItem();
billStateItem.Control = new TextEdit();
billStateItem.Text = "状态";
billStateItem.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
layoutControl1.Root.AddItem(billStateItem, billDateItem, InsertType.Right); LayoutControlItem iotypeItem = new LayoutControlItem();
iotypeItem.Control = new TextEdit();
iotypeItem.Text = "出入库类型";
iotypeItem.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
layoutControl1.Root.AddItem(iotypeItem); LayoutControlItem workshopItem = new LayoutControlItem();
workshopItem.Control = new TextEdit();
workshopItem.Text = "生产车间";
workshopItem.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
layoutControl1.Root.AddItem(workshopItem, iotypeItem, InsertType.Right); LayoutControlItem warehouseItem = new LayoutControlItem();
warehouseItem.Control = new TextEdit();
warehouseItem.Text = "仓库";
warehouseItem.AppearanceItemCaption.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
layoutControl1.Root.AddItem(warehouseItem, iotypeItem, InsertType.Right); layoutControl1.BestFit();
}
}