0

I want to bind a datasource in XtraGrid control but I am not able to do it. The problem is that I have created columns in XtraGrid at design time and I am binding records at run time using a user defined collection.

I created four columns in the XtraGrid at design time. First one is a CheckBox type, second and third one is Default and last one is Button type.

I created a structure in my program:

public struct Test
{
      public bool IsSelect{get; set; }
      public string First{get; set; } 
      public string Second {get; set;}
} 

Then I created a List<Test> collection which contains 10 Test type record. For binding I wrote the following code:

grid1.DataSource = userList; 

Now I want to bind this record in XtraGrid control. IsSelect property should be bound with the CheckBox column and the remaining two properties will bind with the second and third columns.

Is it possible in XtraGrid?

I am using Visual Studio 2010 with .NET Framework 3.5 and C# language.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Awadhendra
  • 513
  • 3
  • 11
  • 22

2 Answers2

0

the XtraGrid is not a standard .NET control but a Developer Express Control...we use them where I work and have found their support line to be very responsive, their website is www.devexpress.com.

That being said, I would think that as long as the FieldName of the columns match the names of the fields within your structure this should work fine.

-Hollis

Hollis
  • 68
  • 5
0

The column fieldname should be set to the objects property fieldname. Once you've added columns in the designer they won't be created automatically anymore.

Read more about it here: Traditional Data Binding Methods http://documentation.devexpress.com/#WindowsForms/CustomDocument2387

Binding Controls to Data Created at Runtime http://documentation.devexpress.com/#WindowsForms/CustomDocument2387

CodingBarfield
  • 3,392
  • 2
  • 27
  • 54