I want to use card view.
I want row height to adjust automatically to text.
How can this be done?
This is my code but row height does not adjust. but stay fixed.
I use v8.1 with .net2
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Infragistics.Win; namespace WindowsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { List<Person> ls = new List<Person>(); ls.Add(new Person("x", "y" + Environment.NewLine + "z")); ls.Add(new Person("1", "2")); ultraGrid1.DataSource = ls; ultraGrid1.DisplayLayout.Bands[0].Columns["Value"].PerformAutoResize(); } private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Bands[0].CardView = true; e.Layout.Bands[0].Columns["Value"].CellMultiLine = DefaultableBoolean.True; //e.Layout.Bands[0].Columns["DESCRIPTION"].CellMultiLine = DefaultableBoolean.True; e.Layout.Override.RowSizing = Infragistics.Win.UltraWinGrid.RowSizing.AutoFree; e.Layout.Bands[0].CardSettings.AutoFit = true; } } public class Person { private string mName; private string mValue; public Person(string name, string value) { Name = name; Value = value; } public string Name { get { return mName; } set { mName = value; } } public string Value { get { return mValue; } set { mValue = value; } } } }
Hello drpoalim,
You can size the cell heights of the grid by setting the UseRowLayout (RowLayoutStyle in newer versions) on the band and then the PrefferedCellSize property to a new size so that the cells’ text will fit in.
How can I calculate the height by text size?
Since some variables are here.
Such as string length, number of new lines, and size of column.
The user can also change size of column, and also change length of text.
So I assume will need to attach to events when column and text size changes .
When it is not card view, all these is done automatically by the grid .