Exemple #1
0
        // populate grid
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // initialize columns: file name, date, size
            _flex.Rows.Count    = 1;
            _flex.Cols.Count    = 4;
            _flex.Cols[0].Width = _flex.Rows.DefaultSize;

            Column c = _flex.Cols[1];

            c.Name     = c.Caption = "Name";
            c.DataType = typeof(string);

            c           = _flex.Cols[2];
            c.Name      = c.Caption = "Last Mod";
            c.DataType  = typeof(DateTime);
            c.TextAlign = c.TextAlignFixed = TextAlignEnum.CenterCenter;

            c           = _flex.Cols[3];
            c.Name      = c.Caption = "Size";
            c.DataType  = typeof(MySize);
            c.TextAlign = c.TextAlignFixed = TextAlignEnum.RightCenter;

            // populate grid
            //
            // note: MySize has a TypeConverter that knows how to convert from longs,
            // so we can assign any longs (fi.Lenght) directly to the "Size" column.
            //
            string sysDir = @"c:\winnt\system32";

            if (!Directory.Exists(sysDir))
            {
                sysDir = @"c:\windows\system32";
            }
            DirectoryInfo di = new DirectoryInfo(sysDir);

            _flex.Rows.Count = 1;
            foreach (FileInfo fi in di.GetFiles())
            {
                _flex.AddItem(new object[] { null, fi.Name, fi.LastWriteTime, fi.Length });
            }
        }