Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# DataGrid template
Hello!
 
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:
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):
 
 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 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 OriginalGriff 304
1 Maciej Los 285
2 Sergey Alexandrovich Kryukov 255
3 Shweta N Mishra 216
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,760


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2014
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