简体   繁体   中英

DataGridView Not Populating

I've worked with web applications and GridViews, but I am working with a DataGridView for the first time now. I thought it would be pretty much the same thing, but I am having a little trouble trying to get it to fill correctly.

Here is what I currently have:

    familiesBindingSource.DataSource = FamilyLogic.GetFamiliesForView();
    FamiliesGridView.DataSource = familiesBindingSource;

The GetFamiliesView() method returns a DataTable. When I open up this form, nothing happens.

EDIT -- added more code..

    DataTable ds = FamilyLogic.GetFamiliesForView();
    familiesBindingSource.DataSource = ds;

    FamiliesGridView.DataSource = familiesBindingSource;

I could also post the GetFamiliesForView() method, but I am 100% sure it's not in there. It's returning the correct info and the DataSource field of the FamiliesGridView does contain the correct information when I step through it.

Welp, I found the issue. I did not realize that I needed these two lines of code.

    FamiliesGridView.Dock = DockStyle.Fill;
    FamiliesGridView.AutoGenerateColumns = true;

Thanks for the help, all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM