在其中包含Xtragrid和LayoutView(layoutView1)。我附加了一个简单的对象,我的对象的每个属性都由一行表示。如何将行宽设置为我想要的宽度?
地址:VS 2010,DXperience 12.2
public partial class Form1 : XtraForm
{
//MyForm ctor
public Form1()
{
InitializeComponent();
AddColumn("First");
AddColumn("Second");
List<Datas> d = new List<Datas>();
d.Add(new Datas());
gridControl1.DataSource = d;
}
void AddColumn(String fieldName)
{
Byte colNum = (Byte)(layoutView1.Columns.Count % columns);
LayoutViewColumn column = layoutView1.Columns.AddField(fieldName);
column.Caption = fieldName;
column.Name = "ColumnName_" + fieldName;
column.LayoutViewField.Name = "layoutViewField_" + fieldName ;
// What should I do with *.Size to make work?
//Now it takes a row from border to border in any case
column.LayoutViewField.Size = new Size(100, 20);
column.LayoutViewField.MaxSize = new Size(100, 20);
}
}
//Simple class for tests
public class Datas
{
public String First { get; set; }
public String Second { get; set; }
public Datas()
{
First = "One";
Second = "Two";
}
}
}
答案 0 :(得分:2)
LayoutView卡布局的主要规则 - 项目应占据整个卡片空间。您可以使用EmptySpaceItem为卡片添加空白区域。
使用布局设计器可以轻松完成:
答案 1 :(得分:-1)
您是否尝试过:
layoutView1.BestFitColumns();
答案 2 :(得分:-2)
使用
layoutView1.OptionsView.ColumnAutoWidth = false;.
layoutView1.BestFitColumns()