Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DataGrid Columns

17 views
Skip to first unread message

David McCallum

unread,
Dec 3, 2008, 9:31:09 AM12/3/08
to
I have a class (MyClass) with a number of public properties, say prop1,
prop2, prop3.....

My DataGrid's data source is a List<MyClass>

The problem is the grid shows all the properties, how do I restrict it ti
show only say prop2 and prop10

TIA

David McCallum

David McCallum

unread,
Dec 3, 2008, 9:52:54 AM12/3/08
to

Arun

unread,
Dec 3, 2008, 2:39:07 PM12/3/08
to

David McCallum

unread,
Dec 3, 2008, 3:00:52 PM12/3/08
to
Arun,
 
Thanks for that, but I already tried that from an example I found. Can you have a look at my code and see if you see anything wrong. The two properties I want to display are FullIC and IcDescription, but as can be seen my the image all the columsn still show.
 
TIA
 
David
 

public

ICSelector(List<IC> ics)

{

InitializeComponent();

ICGrid.DataSource = ics;

this.ics = ics;

 

// Creates two DataGridTableStyle objects, one for the Machine

// array, and one for the Parts ArrayList.

DataGridTableStyle ICTable = new DataGridTableStyle {MappingName = "List<IC>"};

// Sets the MappingName to the class name plus brackets.

 

// Creates three column styles.

var colFullIC = new DataGridTextBoxColumn();

// Property ic.FullIC

colFullIC.MappingName = "FullIC";

colFullIC.HeaderText = "IC";

DataGridTextBoxColumn colDescription = new DataGridTextBoxColumn();

// Property ic.IcDescription

colDescription.MappingName = "IcDescription";

colDescription.HeaderText = "Description";

// Adds the column styles to the grid table style.

ICTable.GridColumnStyles.Add(colFullIC);

ICTable.GridColumnStyles.Add(colDescription);

// Add the table style to the collection, but clear the

// collection first.

ICGrid.TableStyles.Clear();

ICGrid.TableStyles.Add(ICTable);

}

ICSelector.jpg

drozd

unread,
Dec 4, 2008, 3:17:08 AM12/4/08
to
On Dec 3, 9:00 pm, "David McCallum"
>  ICSelector.jpg
> 38KViewDownload

Try setting ICTable.MappingName to the name of the element type, i.e.

DataGridTableStyle ICTable = new DataGridTableStyle {MappingName =

"IC"};

Hope that helps,
Michał

David McCallum

unread,
Dec 4, 2008, 5:23:00 AM12/4/08
to
Michal

>>Try setting ICTable.MappingName to the name of the element type, i.e.

>>DataGridTableStyle ICTable = new DataGridTableStyle {MappingName ="IC"};

Tried that just get the same results

David

Arun

unread,
Dec 4, 2008, 12:11:46 PM12/4/08
to
Try this
DataGridTableStyle ICTable = new DataGridTableStyle();
ICTable.MappingName = ICGrid.DataSource.GetType().Name;

Try this too,
//Do clear default table style before applying customized
ICGrid.TableStyles.Clear();
ICGrid.TableStyles.Add(ICTable);

Hope this helps,
Cheers,
Arun

On Dec 4, 2:23 am, "David McCallum"

David McCallum

unread,
Dec 4, 2008, 2:02:50 PM12/4/08
to
Arun,

>> DataGridTableStyle ICTable = new DataGridTableStyle();
>> ICTable.MappingName = ICGrid.DataSource.GetType().Name;

Thanks that did it, finny thing is I expected
ICGrid.DataSource.GetType().Name to return List, List<T>, List<IC> or
something like that. Instead it returns List`1

Any ideas?

David

"Arun" <arunkuma...@gmail.com> wrote in message
news:94c5053e-cf36-4d1f...@t39g2000prh.googlegroups.com...

commerci...@gmail.com

unread,
Jun 27, 2014, 9:25:11 AM6/27/14
to
This works great for me !
0 new messages