Hello All,

I want to design a DataGrid similar to the one in the design picture attached with this article (Please see the pic attached).
I want the following bindings and features :-

  1. The first column of every Item (Item1,...Item5) for (LineNo=1....LineNo=?) will get bind to "Unit" which is not a collection type or array but its just and a String type property. Similarly, the other columns also are not of collection type but just one property that are Unit (String), Status (String), UnitType (String) and Runtime (Integer).

  2. The object, "MyObj" from which I am getting these property values is of collection type like array and has structure as follows :-

MyObj(0) contains Unit, Status, UnitType, Runtime, ItemNo=1, LineNo=1.
MyObj(1) contains Unit, Status, UnitType, Runtime, ItemNo=2, LineNo=1.
MyObj(2) contains Unit, Status, UnitType, Runtime, ItemNo=3, LineNo=1.
MyObj(3) contains Unit, Status, UnitType, Runtime, ItemNo=4, LineNo=1.
MyObj(4) contains Unit, Status, UnitType, Runtime, ItemNo=5, LineNo=1.
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=1, LineNo=?.
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=2, LineNo=?.
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=3, LineNo=?.
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=4, LineNo=?.
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=5, LineNo=?.

I want to know how to bind these values to the respective cells.
NOTE :- The ItemNo(Column) will always be 1 to 5 and this is fixed however the LineNo(Row) can be anything depending on the object, what it takes from the Database.

Please suggest some way to achieve this as I know its very complex but interesting too.
Kindly express your ideas and please help me accomplish this one.
Thanks in advance to all of you :)

Recommended Answers

All 5 Replies

I would explore the avenue where you design a user control for items, where you add a grid and bind the 5 string columns. and then add and bind 5 of these itemUserControl in your main control's datagrid.

There might be constraints with grids in datagrids never tried it but yeah, i would start there.

Hope this helps, good luck and keep us posted!

Could you please demonstrate the same by giving a brief instance ?

im sorry i have been away for a few days.

I started working with wpf in january and im pretty busy myself but if i get some free time this week ill try and put something together.

If you don't see anything from me by friday then ill be on vacation till march 9th so it'll wait till then :P hope its not urgent !

Its completely fine and thanks for your help for the same...I'll wait for your response on this one :)

Hey, I achieved this one by creating an observable collection of a class and this class holds on to 20 properties which I'm presently setting up in the VM.
Its working perfectly fine now....Thanks anyways for your suggestions and help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.