using C1.Win.C1FlexGrid;
using System;
using System.Windows.Forms;

namespace RowAutoSizeDemo
{
    public partial class Form1 : Form
    {
        C1FlexGrid c1FlexGrid1 = new C1FlexGrid();

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SetupGrid();

            //setting the column visibility to false before resizing, resulting in row height not resizing
            c1FlexGrid1.Cols[1].Visible = false;
            c1FlexGrid1.AutoSizeRows();
            c1FlexGrid1.Cols[1].Visible = true;
        }

        private void SetupGrid()
        {   
            this.Controls.Add(c1FlexGrid1);
            c1FlexGrid1.Dock = DockStyle.Fill;

            c1FlexGrid1.Rows.Count = 5;
            c1FlexGrid1.Cols.Count = 5;
            c1FlexGrid1.Styles.Normal.WordWrap = true;

            c1FlexGrid1[1, 1] = "Very long text, not able to fit in the cell";
        }
    }
}
