PC Review


Reply
Thread Tools Rate Thread

DataGridViewComboBoxColumn, binding collections of objects?

 
 
Simon Tamman
Guest
Posts: n/a
 
      24th Oct 2006
How do other people get around having to define the ValueMember in a
DataGridViewComboBoxColumn when binding to a list of business objects?

I'm currently doing the following, and it feels wrong and woefully
misguided.

public class SomeClass
{
private string name;

public SomeClass(string name)
{
this.name = name;
}

public string Name
{
get{return name;}
}

public object This
{
get{return this;}
}
}

so that I can specify:

DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
column.ValueMember = "Name";
column.ValueMember = "This";
column.DataSource = new List<SomeClass>(new SomeClass[]{new
SomeClass("Fred")});

If I don't do this I get a conversion exception as the datagridview
dutifully attempts to parse a string into an instance of "SomeClass".

Surely there is a better way around this than defining a property that
returns "this". Isn't there?

Simon Tamman


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Explicit interface class implementation binding to DataGridViewComboBoxColumn.ValueMember Ken Microsoft C# .NET 0 4th Mar 2007 09:34 AM
Binging custom objects to the DataGridViewComboBoxColumn =?Utf-8?B?U3RldmUgQnVnZGVu?= Microsoft Dot NET Framework Forms 7 2nd Mar 2007 01:46 AM
Binding object collections to a gridview Chris Microsoft ASP .NET 1 14th Jan 2007 05:36 AM
Binding Custom Collections to Datagrid =?Utf-8?B?U3VyZXNo?= Microsoft ASP .NET 1 22nd Sep 2006 12:04 AM
DataGridViewComboBoxColumn Data Binding Fun zaffle@gmail.com Microsoft Dot NET Framework 2 1st Aug 2006 08:45 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:50 AM.