Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello!

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

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:
http://i45.tinypic.com/2l8yarp.png[^]
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:
http://i45.tinypic.com/2s0ms90.png[^]

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):

C#
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 = "" };
               Produkty.Add(p);
          // }

           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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900