Pergunta

Have an Xtragrid and LayoutView (layoutView1) in it. I have attached a simple object, each propertie of my object is represented by a row. How can I set the row width as wide as I want it to be?

Add.: 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";
        }
    }
}
Foi útil?

Solução

The main rule for the LayoutView card's layout - items should occupy the entire card space. You can use the EmptySpaceItem to add empty space to a card.

It can be accomplished using the Layout Designer with easy: enter image description here

Outras dicas

Have you tried with: layoutView1.BestFitColumns();

Use

layoutView1.OptionsView.ColumnAutoWidth = false;.
layoutView1.BestFitColumns()
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top