I am using Telerik's WinForms controls and have a radGridView which is bound to a bindingsource to display my data. I would like to expand on the functionality of this a bit to give users an extra way to order the records.
I have added two command buttons to the gridview (Up, Down) to help facilitate this functionality. Basically, when the "Up" button is clicked, I would like the current row to switch places with the row above; if the "Down" button is clicked, the current row should switch places with the row below.
Example data:
1
2
3
4
5
If the "Up" button is clicked on the third row, the data should then look like so:
1
3
2
4
5
If the "Down" button is clicked on the third row, the data should look like this:
1
2
4
3
5
How can I achieve this? Do I have to modifiy the bindingsource positions of these rows, or the gridview row's index? Another way? Any examples are greatly appreciated!
Decided to use drag and drop instead of up/down buttons. All is well.
Related
My title may be unclear for the question that I am asking.
What I have is a DataGrid with 5 rows. Upon resizing the window, the rows of the DataGrid is supposed to fill up the DataGrid space, meaning I want the 5 rows to be split evenly.
I have acheived this by doing the following:
DataGrid1.RowHeight = DataGrid1.RenderSize.Height / 5);
However sometimes when I press the down arrow key on the last row of the DataGrid, It will go down another row, which is an empty space. I would like to prevent that. Any help is greatly appreciated.
This is the datagrid with 5 rows of data.
Before
When I select a cell from the last row and press the down arrow, this is what I get:
After
So I created a datagrid view with columns that go one through ten and rows that go 1 through 5 incremented .0 1. What I want to be able to do is accept 5 user given inputs and then search the grid and if those 5 inputs are in the same row in any row, highlight that row. I'm just not sure how to get started. A point in the right direction would be great.
I have 100 items, from items 1 to items 100. I only want to display 5 items each time and when the user click on the down button once, it will display from item 2 to 6. When I click again, it will display from item 3 to 7.
I was thinking to reset the whole datagridview and redraw it once the arrow is clicked. But I am worried it is too slow. Is there a more suitable control for this application?
Having 100 item in a DataGrid is ok IMHO.
However, if you want the fastest possible solution, I suggest you to use a ListView with the VirtualMode enabled.
I am developing a WPF application.
I have list of buttons (for example).
The list is created on run time, and on design time I don't know how many elements(buttons) are going to be in the list.
I want to order the elements in a symmetric way based on the number of buttons.
For example:
If the list contains 4 buttons, I want the grid to have 2 rows and 2
columns.
If the list contains 6 buttons, I want the grid to have 2 rows and 3
columns.
If the list contains 9 buttons, I want the grid to have 3 rows and 3
columns.
Is there a way to create this kind of grid?
What panel should I be using?
You can use WPF Grid container control. Add RowDefinitions and ColumnDefinitions to the Grid as per your requirement.
Another approach is to use a WrapPanel with a fix ItemHeight and ItemWidth.
I have to filter GridView data based on the Tab Panel selected,
Here is the scenario:
I have the following tabs
All | Tab A | Tab B | Tab C
When I click on "All" tab, I get 10 records and my GridView contains 10 records,
But when I click on Tab A, my GridView need to filter and show 5 records
Right now, I am using the separate GridView for each tab and binding to same DataSourceID.
And using OnActiveTabChanged event to filter the data, but this is invoking underlying method to-execute 4 times (because of 4 tab panels), no problem with the user experience but
there is performance issue...
I am trying to see, if I can use the :
Same GrigView in all the Tab Panels for this type of scenario
Any help is much appreciate, thanks!!
If you want to use a single GridView on all tabs, try invoking the underlying method (that populates the GridView) in OnPreRender instead of OnActiveTabChanged. Make it conditional on which tab is active, and filter accordingly.
You can use the RowFilter property on a DataView and have each tab apply the one you need.
ie DataView1.RowFilter = "Column='ColumnValue'" then set the datasource/databind.