Click here to Skip to main content
11,490,282 members (63,069 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# DataGrid template

I've created datagrid with combobox (reading data from DB), but need to fix some problems, maybe someone of you can help me Wink | ;)

First of all, I used grouping in dataGrid (group by name Wzór#), and everytime I want to add new element, it shows on the bottom:[^]
Is it possible, to create something like "new group" with this only (the new one) item? For example like:
Wzór 1
Wzór1 niebieski 22 1 1 1
Wzór1 czerwony 23 1 1 1
Wzór 2
Wzór 2 czarny 55 1 1 1
Add new item
ComboBox ComBox ComboBox TextBox TextBox TextBox (which are exactly same as marked in picture). I mean somethink like that:[^]

Second problem i found is that, when Im adding new item, and changing anything in ComboBox1,2 or 3 and then when im begining edit any textbox, all values from combobox dissapear - any way to fix it?

Here is source code (Actually its not very complicated, i have 3 methods with fill combobox1, combobox2 and combobox3 from database, then after button click im creating new Product item which im adding to list):

 wzoryCount = wzoryCB.Items.Count;
            List<Produkt> Produkty = new List<Produkt>();
           // for (int i = 0; i < wzoryCount; i++)
                Produkt p = new Produkt { wzor = "", kolor = "", cena = 0, rozmiar = "", indeks = "", kod = "" };
           // }
            dataGrid1.ItemsSource = Produkty;
            ListCollectionView collection = new ListCollectionView(Produkty);
            collection.GroupDescriptions.Add(new PropertyGroupDescription("wzor"));
            dataGrid1.ItemsSource = collection;

I guess, i need to do something in beginEdit method for datagrid, but when i put there messagebox, it doesnt appear when im changing anything in combobox, but do when im changing textbox.

Thanks for any help!
Posted 4-Dec-12 2:41am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 650
1 Andy Lanng 233
2 OriginalGriff 188
3 Sascha Lefèvre 170
4 Maciej Los 160
0 Sergey Alexandrovich Kryukov 9,713
1 OriginalGriff 8,475
2 Sascha Lefèvre 3,504
3 Maciej Los 3,106
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100