0

I'm getting a weird behavior with a datagrid. No matter what I do, it's ordering the columns arbitrarily and adding all the columns in the objects.

I'm using .NET 3.5, with a winforms datagrid. The Datasource is set at runtime, not design time. I've tried defining the columns in the GDI, but it ignores the order. Even if I only define one item, it displays the every public property on the list I pass in.

List<EventLog> events = service.GetEvents();
EventLogList.DataSource = events;
EventLogList.AutoGenerateColumns = false;
EventLogList.Refresh();

EventLog is an object generated by Linq2Sql. It passes back a view. The grid always shows every column, regardless of what I do to the columns object in the designer.

2 Answers 2

2

Is the AutoGenerateColumns property set to false?

Sign up to request clarification or add additional context in comments.

1 Comment

It was, but I was setting it to false after setting the datasource not before.
0

Set AutoGenerateColumns = false BEFORE setting the datasource....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.