473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do i bind such a class to datagrid?


class Document
{
Hashtable Properties ; //Key is the property name
}

class Media
{
Document document;
Status status
string this[string propertyName] //Return property value from the
document
{
}

}

I have a list of media and I would like to bind it to a grid In such a away
that
each property of the document will be displayed in a different column
Thanks in advance
Nov 17 '05 #1
4 1209
From the information given, it is impossible. Consider that Medium M1
has properties A & B, while Medium M2 has properties C & D. How could it
even draw the heading column, when it won't know what those heading will be
until it's finished processing every row?

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

"Julia" <co********@012.net.il> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...

class Document
{
Hashtable Properties ; //Key is the property name
}

class Media
{
Document document;
Status status
string this[string propertyName] //Return property value from the
document
{
}

}

I have a list of media and I would like to bind it to a grid In such a away that
each property of the document will be displayed in a different column
Thanks in advance

Nov 17 '05 #2
No!!!

after loading the list with the media,all media in the list have the same
properties


"James Curran" <ja*********@mvps.org> wrote in message
news:OR***************@TK2MSFTNGP09.phx.gbl...
From the information given, it is impossible. Consider that Medium M1
has properties A & B, while Medium M2 has properties C & D. How could it
even draw the heading column, when it won't know what those heading will be until it's finished processing every row?

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

"Julia" <co********@012.net.il> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...

class Document
{
Hashtable Properties ; //Key is the property name
}

class Media
{
Document document;
Status status
string this[string propertyName] //Return property value from the
document
{
}

}

I have a list of media and I would like to bind it to a grid In such a

away
that
each property of the document will be displayed in a different column
Thanks in advance


Nov 17 '05 #3
Julia wrote:
class Document
{
Hashtable Properties ; //Key is the property name
}

class Media
{
Document document;
Status status
string this[string propertyName] //Return property value from the
document
{
}

}

I have a list of media and I would like to bind it to a grid In such a away
that
each property of the document will be displayed in a different column


Implement ICustomTypeDescriptor on Document. It comes down to the fact
that you have to supply a PropertyDescriptorCollection, which for each
property you want to expose a PropertyDescriptor instance. You therefore
have to implement a class derived from PropertyDescriptor.

For each entry in the hashtable 'Properties' you then create a property
descriptor and return it in Document.GetProperties. When you then bind a
collection of Document instances to a grid, each property in the
document will show up as a column.

Be aware though that all document instances in the collection you bind
have to have the same properties.

Frans
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 17 '05 #4
"Julia" <co********@012.net.il> wrote in message
news:em**************@TK2MSFTNGP12.phx.gbl...
No!!!

after loading the list with the media,all media in the list have the same
properties


You know that.... But how is the DataGrid? (Well, Frans explains how,
but it's extra work...)

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: coleenholley | last post by:
I have a Class Module written in VB that calls an RPC (written in COBOL) we have written code to read the data from the RPC, and we create a temporary datatable to store the data from the RPC. This...
2
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple...
1
by: Doug D via .NET 247 | last post by:
I really really need some insight on this problem I am trying to bind a strongly typed collection object to a datagrid. I already Inherited CollectionBase, but .NET says that it cannot find my...
2
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple...
1
by: Øyvind Isaksen | last post by:
I try to make my own ArticleAttribute object and ArticleAttributeCollection, and add data to this Collection. It almost works, but the problem is that each time I add an ArticleAttribute to my...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.