Display dictionary

R

RedLars

Hi,

What is a flexible way of displaying the content of MyClass in an UI?
Would DataGridView be a good solution or ? Could I for instance bind
myclass directly to datagridview or would I need to manually iterate
through the class? MyClass will restrict the max size of allowed x and
y values.

public struct Pair
{
public uint x; // range between 0 and 10
public uint y; // range between 0 and 10
}

public class MyClass
{
private Dictionary<Pair, string> m_collection = new
Dictionary<Pair, string>();
public void Add(Pair p, string s) {... }
public void Remove(Pair p) {... }
}
 
P

Peter Duniho

Hi,

What is a flexible way of displaying the content of MyClass in an UI?
Would DataGridView be a good solution or ? Could I for instance bind
myclass directly to datagridview or would I need to manually iterate
through the class?

Have you tried using binding? What happens? Does it produce the results
you want? If so, great. If not, in what way are those results not what
you wanted or expected?
MyClass will restrict the max size of allowed x and
y values.

Is this relevant to the question? I can't tell why, so if it is you
should elaborate on the point.

Pete
 
R

RedLars

Have you tried using binding?  What happens?  Does it produce the results  
you want?  If so, great.  If not, in what way are those results not what  
you wanted or expected?

Yes I did try using the binding and it did not show the content of the
class.

Hence I wanted to know if it was possible to bind a custom class to
the DataGridView.
 
P

Peter Duniho

Yes I did try using the binding and it did not show the content of the
class.

Sorry, that's not a specific enough answer to be useful in providing an
answer.
Hence I wanted to know if it was possible to bind a custom class to
the DataGridView.

It is, but you'll have to implement the necessary binding support features
in your class. For example, the IBindingList interface. The exact best
way to do it depends on what exactly you're trying to accomplish, but if
you look at the documentation describing binding, you should get some
ideas.

If you search MSDN for "data binding", this is one of the early hits in
the results:
http://msdn.microsoft.com/en-us/library/c8aebh9k.aspx

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top