I have a MainGrid in Wpf (not a DataGrid) it has 3 rows(0.1 and 2) i have made rows using xaml at design time now at run time behind a menu button i want to add 2 column to row 1 of the main grid.
The hard part is that only break the row 1 into 2 columnn and not the whole Grid.
i know that to add new rows and columns one can use rowdefination and columndefination but
couldnt find anything here:
MainGrid.RowDefinitions.ElementAt(1).SetValue...;
Thanks
Why don't you add a Grid with 1 row and 2 columns to that row instead. And put your contents in that Grid. That will be easier.
make the column span = 2 for all the controls that you add in row 2 and 3...
Related
I have the following form:
1) Label -> ComboBox
2) Label -> ComboBox
3) Label -> RadioBox
4) additional items
I want to insert a new ComboBox between row 2 to row 3 and to move other elements.
How can i do it? is the best solution to create a hidden ComboBox and then make it visible? or should i create a dynamic ComboBox?
Thanks!
I would put my controls into a TableLayoutPanel and then you can simply insert new RowStyles into it. And Columns for that matter, if need be.
As for moving things, you can always reassign the Row and Column indexes for the controls, effectively assigning them to new grid cells within the TableLayoutPanel.
I was working with grid-view,I try to enter some text on cell 1 on 0th row
it automatically increment other rows and I again try to write some on cell 2 on the same 0th row ,Simultaneously increments other rows.
So for I tried with
dataGridView1.AllowUserToAddRows=true;
It doesn't allow me to write inside a gridview, I think click rows has to generate automatically.
Please resolve this logic based on Cell Value Changed events.
It is not a good practice to add rows to your gridview. If you want to add something to your view, add them to the data that you are binding to it, and then bind. Very easy.
So you have something like this:
List<MyType> data = ReadDataFromSomewhere();
data.Add(new MyType(){StringItem="Something", IntItem =0});//Adding your row
data.Insert(1,new MyType(){StringItem="Other Thing", IntItem =1});//Inserting to position 1
gv.DataSource = data;
gv.DataBind();
i have a question: is there any way to show a single row of a table in two rows? The problem is that my table has too many fields and is too wide. So, I think that maybe you can split each row in the table to make it in a row. For example (my idea in Excel, just for example):
Complete table
...and my idea
I hope for your help!
You can:
add a Tablix with 4 columns and without header
add a Rectangle in every detail cell
add 4 TextBox for every Rectangle: use 2 TextBox as labels and two TextBox as values
increase Rectangle height in order to put spaces between every rows
Once you perform this operation for value 1 and 5, you can copy and paste Rectangle in the other 3 cells and simply change label and value.
I'd like to "freeze" the columns and rows in WPF.
I want to implement a table (state machine), where in the first row are states and in first column are commands. The rest of the cells are filled with events.
To improve usability, I'd like to keep the first row and first column visible all the time, so even at the very bottom of the table the states and commands are visible.
The DataGrid offers this kind of functionality but DataGrid cells don't look flexible enough. I'd like to use Grid.
The ScrollViewer is basically what I need, but i haven't figured out how to use it for multiple Grids at the same time.
Is there any way to freeze first row and first column (at the same time)?
I don't think that there is no way to freeze columns or rows of a Grid. But you can use 4 Grids. Syncronize the Column and Rowsize with SharedSizeGroup.
I have a dataGridView which has about 30 rows in it and last row of it contains sum of all the cells in that particular column. Now I would like to freeze the last row which has sum while still allowing the remaining rows to scroll.
dataGridViewPaymentsReceived.Rows[dataGridViewPaymentsReceived.Rows.Count-1].Frozen = true;
The above code freezes the entire dataGridView and doesn't allow me to scroll on it.
Can anyone suggest me a good way to keep the last row displayed all the time even when I scroll on the dataGridView?
The easiest solution would be to create a second DataGridView directly below the first. Then manually populate it with the single row that you want to be displayed every time the first datagrid binds to data.
To make it appear totally seamless, don't forget to hide the column headers in the 2nd datagrid:
dataGridView2.ColumnHeadersVisible = false;
See this answer for more info.