DataGridViewComboBoxColumn duplicate entry form child tables.

A

artur_mis

I have got tables:

ptyp(child table, id primary):
+----+---------+--------+---------+
| id | name | length | density |
+----+---------+--------+---------+
| 1 | kwidzyn | 780 | 45 |
| 2 | kwidzyn | 1170 | 45 |
| 3 | myszkow | 780 | 45 |
+----+---------+--------+---------+

zpaper(main table,id primary key, typ foregin key):
+------------+---------+-------+----+------+
| data | stan | ilosc | id | typ |
+------------+---------+-------+----+------+
| 2008-11-12 | dostawa | 3 | 1 | 2 |
| 2008-11-12 | zwrot | 3 | 2 | 1 |
| 2007-09-09 | dostawa | 4 | 3 | 2 |
+------------+---------+-------+----+------+

the tables are connected via key zpaper.typ and ptyp.id.

DGV consist of ( ptyp.data, p.typ.stan, ptyp.ilosc,
zpaper.typ(datagridcomboboxcolumn) )
In cloumn of DGV zpaper.typ i would like have only not duplicated
values from zpaper.stan.

The part f code looks like this :

DataGridViewComboBoxColumn cbcol2 = new
DataGridViewComboBoxColumn();

cbcol2.HeaderText = "Dostawca";

cbcol2.DataPropertyName = "typ"; //pierwsza tabela wezel.

cbcol2.DisplayMember = "name";//to co wyswietlamy z drugiej
tabeli.

cbcol2.ValueMember = "id"; // druga tabela wezel.

cbcol2.DataSource = bs2

DGV.Columns.Add(cbcol2);

Other colums are binded to bs1.



where:
bs1.DataSource = ds.Tables["zpapier"];
bs2.DataSource = ds.Tables["ptyp"];

The result i have is duplicated entry for string "kwidzyn".Is it way
to change this situation to behavior:
- one string kwidzyn (now i have double).
- when i set kwidzyn in combo in other column (for example combo)
will occure all length 780 and 1170 ?
- do i need to change data base ?

Regards.
Beginer in csh.
 
Y

yoawaoy

In easier way
May by not clear i described my problem so in easier way:


Let's say i have tableA;

name1 name2
Tom | Smith
Ann |Bonn
Adam | Smith
DGV consist of two colums name1 textcolumn , name2 --
datagridviewcombobox.

Is way to make not duplicated value in DataGridviewCombobox ?
Now i have twice Smith values and one Bonn.
 

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

Similar Threads


Top