ok, I've solved this part. the trick was processing the
defaulvaluesneeded of the datagridview control. Now, I'm facing another
problem: when I delete a column, I'm generating an exception. This only
happens when i have  a datagridviewcomboboxcolumn. Any clues?

thanks

Luis

Hello.

I'm trying to bind a datagridviewcomboboxcolumn to a specific column of a
dataset. The dataset has the following tables:

Table Contacts
* IdContacts
* Contact
* IdUser
* IdTypeContacts

Table TypeContacts
* IdTypeContacts
* Description

The dataset also has established a relationship between
Contacts.IdTypeContas and TypeContacts.IdTypeContacts. The datagridview has
only 2 columns, which should be bound to Contact and IdTypeContacts (table
Contacts). The IdTypeContacts column should show a combo box (which should
contain the description instead of the values). During the OnLoad event, I'm
setting the datasource property of the IdTypeContacts datagridview column to
the  2nd table on the dataset (TypeContacts) with the folowing code:

This.datagridviewcomboboxcolumn.DataSource = _ds.Tables["TypeContacts"];
This.datagridviewcomboboxcolumn.DisplayMember = "Descricao";
This.datagridviewcomboboxcolumn.ValueMember = "IdTiposContactos";

However, if I add this line, that sets the relation between the 2nd column
of the grid and the dataset:

This.datagridviewcomboboxcolumn.DataPropertuName = "Descricao";

I generate an exception when I open the combo box (by clicking on it) at
runtime. The exception says something like this:
"Index -1 is either negative or above rows count"

I'm I doing anything wrong?

Thanks.

Regards,
Luis

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com




=================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to