troubleshooting Question

datagridview how do I set columns and settings after binding to a list of objects?

Avatar of jackjohnson44
jackjohnson44 asked on
.NET ProgrammingC#
3 Comments1 Solution458 ViewsLast Modified:
I have a ton of dataviews bound to lists of objects.

I don't need all columns so I do things like
var data = (from item in AllItems
select new
grid.datasource = data;

This works well for testing purposes but I need to make the grids look a little nicer.  For example, some grids could have ID columns I don't want shown.

I am looking for a way to make a central area to define my grids so I can reuse the layout.  For example, I could have a
public static void CreateGridItems(DataGridView dgv)

I'm wondering what is the best way to setup a grid if I want to through code?  Is my example above good? Is there some pattern I should follow, or a better way to do this?  Since I will want to set column width, hide columns etc, so I am not just looking for a subclass of my main object.  The goal is to setup the grid, not just filter out columns.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros