UniformGrid Layout - c#

I know that Uniform grid does not support row span, but its somehow possible by overriding a method from what i read on Google, but i could really use an example how can i do this. What i want to achieve is a layout similar to this:
----------
| 1 | 2 |
----------
| 3 |
----------
So basically i want the third children to be spanned over 2 columns. I could use a grid but sadly i don't know any method how can i do this because all the children's are created dynamically and i cannot specify in witch cell the child will be put.

I think that you'd be better off using a Grid control. Although you say that you cannot specify in which cell the child will be put, I would try to fix that problem, rather than to create a new control. If you can fix that issue, then this might help you.
To populate a particular row in code, you can use the Grid.SetRow method and to populate a particular column, you can use the Grid.SetColumn method:
Grid.SetRow(rectangle, 1);
Grid.SetColumn(rectangle, 1);
Likewise, to set a row span, you can use the Grid.SetRowSpan method and to set a column span, you can use the Grid.SetColumnSpan method:
Grid.SetRowSpan(rectangle, 2);
Grid.SetColumnSpan(rectangle, 2);
Please see the Grid.SetRow Method, Grid.SetRowSpan Method , Grid.SetColumn Method and Grid.SetColumnSpan Method pages on MSDN for a full example on this.

Related

How to hold state of label (color, location)

In Window Forms I have TabControl with 2 tabs. On second tab I add dynamically in for loop labels from xml file based on cords in xml file. When I click on whichever label shows up new Form with three buttons (Important, Total, Address). When I choose for example important label must change color on Orange (I can handle that). My problem is how to save state (color, location) of these label which was clicked. I need that, because state of these labels which was clicked go to database. I have no idea how to save or hold it this state.
You have to make your labes referrable in code. For example by giving them unique names once you create them from XML, like "lblNode141".
Next, if you say, they "go to database" you should have a place there where you can store that information. For example, you could create a table like this:
LabelName | X | Y | Color
-----------------------------
lblNode141 | 20| 30| #577ae4
lblNode142 | 20| 60| #ff8000
lblNode143 | 20| 90| #14bfb2
Now, the next time you create your labels from the same XML, you can retrieve the chosen values from the database. Just query over the name, given that it is unique. You may need to extend those names to get them really unique, I don't have enough information about that.
Note, this is ONE possible solution - depending on what you really want to achieve, this might not perfectly fit your needs.
Solved:
In for loop I've add each one label to List, and in other Button I've check in foreach which label has color and location I needed.

xceed datagrid: How to add an unbound column, that contains a calculated value with inputs from other columns

As the title describes it basically, I want to add an unbound column that contains a value, which is calculated from two existing column values.
Is there a simple way of doing it in XAML like an expression?
So far I havenĀ“t found anything close to my problem even though I think this is a pretty common use case.
I dont think there is a simple xaml only way for this.
I can think of two possible solutions:
First is to use a Multibinding for your calculated column where the calcation happens in the Multibindin-Converter.
Second would be to add a Property to your backing DataClass representing your calculated value and let the calculation happen there and simply bind to that property.

TableLayoutPanel fill top-to-bottom instead of left-to-right?

Is it possible to have a System.Windows.Forms.TableLayoutPanel fill a column before moving to the next one? Regardless of how I set the RowCount, ColumnCount, and GrowStyle, the table is always populated like this:
1 2 3
4 5 6
and I want this:
1 3 5
2 4 6
Can a TableLayoutPanel not automatically do this?
Edit - To clarify, I am adding the controls programmatically.
Not much you can do about it. It's just how TableLayoutControlCollection.Add is implemented internally. I see two options:
Use TableLayoutControlCollection.Add(Control, column, row). But that's quite a hassle, because you need to calculate the column/row values each time you add a control.
Create a derived control that overrides Add and implement it as the overload above - but now internally.

How to create the following user interface?

A customer has asked for a user interface which combines a number of different elements. It's basically a list. Selecting an entry in the list causes a dialog to expand in-place:
Item 1
Item 2
Item 3
After selecting Item 2
Item 1
------------------------------------
| Item 2 |
| text box button |
| button |
| |
| text box button |
------------------------------------
Item 3
I know you can make some fairly complex listviews http://www.codeproject.com/KB/list/ObjectListView.aspx
How would some of you GUI experts do this? Is there a name for this type of layered interface that I could just search on to learn more about it? Can I just extend listviewitem with my in-line form? I think I just need a pointer as to how to start. I've done some forms programming but this is beyond my current knowledge.
Thanks
Edit --
Dash's comment set me on the right track as I think it's an accordion control that I'm looking for. Since he didn't provide an answer I don't know how to mark this as answered...
If you're using WinForms, there's an implementation called DropDownPanel on CodeProject that looks like what you want.
This answer to a similar question describes a possible solution using TableLayoutPanel, which you may also be interested in.
I suggest TableLayoutPanel with 6 rows and 1 column with this orientation:
Row1: Flat button with text=Item1
Row2: A panel corresponding Item1(visible false else button in row1 pressed)
....
and so on.
Note:
First row2,4,6 visible=false
When any button in row1,3,5 is pressed depend on position single row 2,3,4 visible =true else visible=false.
Have you looked at the WPF expander control? You could incorporate this into your list to create a composite control which would satisfy the 'layering' you wish to create.

Display Table (SQL data) with static & dynamic cells in ASP.NET

good day gurus!
I'm new to ASP.NET and I'm still in the process of learning it.
I was able to finish a couple of aspx pages through searching google but I can't seem to get this one page to work.
Basically, I'm trying to display a table (data fetched from SQL table).
All data are fetched from SQL table except for these static cells:
Item | Jan | Feb | March | April | Total
Sponge | Rod | Clock | Paper | Prod Cost | Profit
(and all the SUMS)
The "Adjust1" is inserted there if its values are not null. And this "Adjust1" also affects the "Total".
I hope someone can point me to the right direction.
Thanks a lot for your time,
Pod
use gridview template feild, just not bind data to your static feild
You can bind your dataset directly to a GrdiView control, and without much manipulation, it will output the columns and rows exactly like your dataset that you returned from the DB.
However, I'm not clear as to what you mean to do with the 'Adjust1' row. Can you explain this in a little more detail?
for the sql manipulation it will be much easier and clean, and create the dataset such a way that it look a like the gridview. This will be a more flexible approach as in future if you want to change any header say display January in place of Jan you dont need any new publish but just a sp update in database
I still you do not want to go with db you can any time achieve this task by using grid rowbound event. Add template fields for calculated columns like total, for displaying the header such jan,feb you can use the headertext property of bound field. For add the value in item field you can pass -1 in the dataset and while bound the grid based on the row index replace the text with required values.
for more details on row databound event read this http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

Categories