473,657 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGridViewCom boBoxColumn, binding collections of objects?

How do other people get around having to define the ValueMember in a
DataGridViewCom boBoxColumn 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(strin g name)
{
this.name = name;
}

public string Name
{
get{return name;}
}

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

so that I can specify:

DataGridViewCom boBoxColumn column = new DataGridViewCom boBoxColumn();
column.ValueMem ber = "Name";
column.ValueMem ber = "This";
column.DataSour ce = 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
Oct 23 '06 #1
0 2957

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

Similar topics

1
1247
by: rufus | last post by:
Hi, i am relatively new to dotnet and am working on a project that requires me to bind to objects instead of datasets. The reason for this is that we are using an OR mapper to generate these custom data objects. I know that web controls can bind to any type of object as long as it implements the IEnumerable interface. I have created a custom collection class that inherits from HashTable. I can then bind collections to my web controls.
1
2718
by: Dot net work | last post by:
Hello. I have an interesting data binding scenario: I have a repeater control. It repeats a typical custom web user control. I also have a collection object, and each collection element contains various pieces of information inside a custom object, including an id field.
3
22142
by: Rain County | last post by:
I am programmatically building and populating a table and then making it the data source for a dataGridView. I want to add a column to the dataGridView which will be a DataGridViewComboBoxColumn. I wish to populate, by default, all of the ComboBoxes with the same list of three choices. How do I add the DataGridViewComboBoxColumn, and do I first populate one as a template for the others? I will appreciate any help.
4
2559
by: kin | last post by:
After a I read Walkthrough: Connecting to Data in Objects (http://msdn2.microsoft.com/en-us/library/ms171892.aspx#Mtps_DropDownFilterText). I still have project on that. My School project provided me an array of objects - News, but VS 2005 seams only accept Collections like IList<News> for DataBinding. I can convert an array to IList<News> list = (IList<News>)news, but IList is not a class, so I tried to create a class that extends...
4
7553
by: John | last post by:
Hi, I've been trying to populate a DataGridViewComboBoxColumn with objects. The object is defined as : private struct manufactItem { public string name; public Guid? man_id;
0
1159
by: Chris Botha | last post by:
Using VS2005, on the form is a DataGridView, a typed DataSet containing the data and a BindingSource between the grid and the dataset. One of the columns is a DataGridViewComboBoxColumn, doing what it should, displaying text in the grid while binding to an integer ID field. I can filter the grid perfectly on the text being displayed for this column, by using: BindingSource1.Filter = "TheColName Like 'abc%'" However when sorting on...
1
1918
by: Suresh | last post by:
Using ASP.NET 1.1 ---------------------- I have a custom collection of object that I'm binding to a datagrid. Each of these objects have another collection inside them. I have a user control that renders the nested collection into html table. See sample code below. Now this binds fine and my sub collections are rendered fine by my user control and list appears as it should. The problem is when I do paging. The sub collections do...
0
2206
by: Ken | last post by:
Hi I have a little application that does datavalidation. It supports dynamically loaded plugins (you drop a dll with a class implementing IValidator<Tin the same dir as the main application). All classes that implement this interface are shown in a drop down in a DataGridViewComboBoxColumn named Validator. By choosing the class to validate this specific data in the drop downbox IValidator<T>.Validate is called and returns true/false....
1
2144
by: sklett | last post by:
I have a DataGridView bound to a custom business object. The business object has 2 attributes that are FKs to a lookup table (think HairColorID, EyeColorID, etc) For these 2 columns I have created DataGridViewComboBoxColumn and hooked them up to BindingSources that populate them with the lookup table's value (in edit mode) When editing a row and selecting one of the item from the DataGridViewComboBoxColumn cell, the value that is...
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.