DataGridView MetroFramework Source Code

datagridview-metroframework

You may also like...

  • carloscoelho

    hello how to write xml using metrogrid im read not write xml im get error

    • I think the easiest way for this is to load the xml first in datatable, then after made some changes on the metrogrid, write the xml using datatable

  • carloscoelho

    Exite ! tanks

    private void configform_Load(object sender, EventArgs e)

    {
    DataTable _table = new DataTable();
    //Load SCHEMA MICROSOFT
    _table.ReadXml(Application.StartupPath + @”Datasch.xml”);
    //Load Tables separeted
    _table.ReadXml(Application.StartupPath + @”DataBooks.xml”);

    metroGrid1.DataSource = _table;
    metroGrid1.Font = new Font(“Segoe UI”, 11f, FontStyle.Regular, GraphicsUnit.Pixel);
    metroGrid1.AllowUserToAddRows = true;
    metroGrid1.Refresh();
    _table.EndInit();
    }

    private void metroGrid1_UserAddedRow(object sender, DataGridViewRowEventArgs e)
    {
    string fileName = (Application.StartupPath + @”DataBooks.xml”);
    DataTable _table = (DataTable)metroGrid1.DataSource;
    _table.WriteXml(fileName);
    }

  • Laurence Salvador

    Hello Sir denise i only needed how to put scroll bars in metrogrid how to do it , please reply thanks

    • Scrollbar will automatically be displayed when your mouse is at the side or bottom of the grid.

      • Laurence Salvador

        Thanks Sir, It works, another question, This code works on default datagridview to autosize colums in datagrid //dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; how to do it in your metrogrid? so that i wont resize the columns everytime I’ll view the table, Thanks!

        • Laurence Salvador

          And also how do you filter data using metrogrid itself? I want to do the filter like yours, to avoid using comboxes and textboxes for filtering.

          • Actually this is one is made using C1Flexgrid that is why there is default filtering. For default MetroGrid it is not available.

        • It should work just like with default DataGrid. MetroGrid was inherited from default DataGrid

          • Thenndral

            Hello Dennis,

            //It should work just like with default DataGrid.

            It means we can use same as VS Data grid and also can change text to combobox column or checkbox column right? Please let me know. I’m struggling in this area.

            Thanks,
            Thenndral.

          • Thenndral

            Hi Dennis,

            I found it is same as VS default grid( as you said). I worked on it.
            I have another question. I can i increase the combobox height. ie. How I see at-least 5 values. now I can view only 2 values then i need to scroll down to view next values.How can I achieve this?

            If any others looking for combobox sample . here is it.

            With MGrid

            .ColumnCount = 3

            .RowHeadersVisible = False

            .AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None

            .AllowUserToResizeRows = False

            .CellBorderStyle = DataGridViewCellBorderStyle.Raised

            .RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single

            .ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single

            .Columns(0).Name = “ID”

            .Columns(0).Width = 100

            .Columns(1).Name = “Name”

            .Columns(1).Width = 200

            Dim cmb As New DataGridViewComboBoxColumn()

            cmb.HeaderText = “Subject”

            cmb.Name = “cmb”

            cmb.FlatStyle = FlatStyle.Flat

            cmb.MaxDropDownItems = 2

            cmb.Width = 200

            cmb.Items.Add(“English”)

            cmb.Items.Add(“Maths”)

            cmb.Items.Add(“Science”)

            cmb.Items.Add(“History1”)

            cmb.Items.Add(“History2”)

            cmb.Items.Add(“History3”)

            .Columns.Insert(2, cmb)

            .Columns(3).Name = “Class”

            .Columns(3).Width = 100

            End With

            Thanks,
            Thenndral

  • Dan Golding

    Hi, I can’t get the row headers to display values using MetroGrid. I am trying this, but the number don’t display

    private void frmSSOList_Load(object sender, EventArgs e)
    {
    foreach (DataGridViewRow row in dgvSSOList.Rows)
    {
    row.HeaderCell.Value = String.Format(“{0}”, row.Index + 1);
    }
    }

    private void dgvSSOList_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
    {
    dgvSSOList.Rows[e.RowIndex].HeaderCell.Value = String.Format(“{0}”, e.RowIndex);
    }

  • Idddrisu Dawuda

    Hi I have created a great desktop app with the help of metro framework but my problem is with the metro gridview when it loads or my data from the database becomes white so one cannot see the records unless u pass the mouse over a row or a column pls any help https://uploads.disquscdn.com/images/bb38915300257b1272a021608215c00d5d00c9a9196be0e7380a380da56529a4.jpg I will be much grateful if I can get help