Home Forums WinForms controls Xceed Grid for WinForms XCeed Grid Winform net unbound

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16216 |

    how can i create the grid dynamically ?

    my code:

    namespace xceed
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                ProvideData();
            }

            public void ProvideData()
            {
                GridControl gridControl1 = new GridControl();

                Column columnName = new Column(“Name”);
                Column columnBirthDate = new Column(“BirthDate”, typeof(DateTime));
                Column columnSex = new Column(“Sex”);
                Column columnMarried = new Column(“Married”, typeof(bool));

                gridControl1.Columns.Add(columnName);
                gridControl1.Columns.Add(columnBirthDate);
                gridControl1.Columns.Add(columnSex);
                gridControl1.Columns.Add(columnMarried);
                gridControl1.CreateControl();
                this.Controls.Add(gridControl1);
                
                gridControl1.BeginInit(); // EndInit will be called later

                Xceed.Grid.DataRow row1 = gridControl1.DataRows.AddNew();
                row1.Cells[“Name”].Value = “George Parson”;
                row1.Cells[“BirthDate”].Value = new DateTime(65, 11, 12);
                row1.Cells[“Sex”].Value = “Male”;
                row1.Cells[“Married”].Value = false;
                row1.EndEdit();

                Xceed.Grid.DataRow row2 = gridControl1.DataRows.AddNew();
                row2.Cells[“Name”].Value = “Melissa Franklin”;
                row2.Cells[“BirthDate”].Value = new DateTime(70, 09, 23);
                row2.Cells[“Sex”].Value = “Female”;
                row2.Cells[“Married”].Value = false;
                row2.EndEdit();           
            }
        }
    }

    with this code i don´t see any Data

     

     

    Imported from legacy forums. Posted by Rene (had 728 views)

    User (Old forums)
    Member
    Post count: 23064

    You are missing the ColumnManagerRow.

      ColumnManagerRow headerRow = new ColumnManagerRow();

      gridControl1.FixedHeaderRows.Add( headerRow );

    A useful tip to learn how to use the grid (or any control for that matter) is to do what you want in the designer, then look at the code that is generated, and simply reproduce the same in your application.

    Imported from legacy forums. Posted by André (had 955 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.