I am currently working on a project that displays user data in a grid, each user has a total and when clicked expands out to show the sub items that make up that total and they can be expanded again to show even more details.
I currently achieve this by using a DataGridView with its data bound to a DataTable, I hide the sub items for each user in the "RowsAdded" event and then just show/hide them as the main user lines/sub lines are clicked.
The Main problem with this is the scroll bar jumps a lot when data is changed and I require it to only move when the user wants it to.
I also have a requirement that no line must ever be covered and the parent lines should show totals of the values in the child (I can do this part manually the more important part is that its not a grouping like with a outlook style list).
My question is: Is there a better way to have expanding entries in a table format? And if hiding and un-hiding is the only way then any idea how to fix the scrolling problem?
I have tried hiding and showing lines as I have already said and I have also tried hiding and showing another Control (in this case another DataGridView) the problem with this approach is that it covers the other rows as I have yet to find a suable way to pad out a space for the control to be in.
You can use the following code to eliminate the scrolling animation.
dataGridView1.ScrollBars = ScrollBars.None;
// Do your show/hide on your datagridview rows
dataGridView1.ScrollBars = ScrollBars.Both;
In the End there was no satisfactory way to do this with winforms so I was forced to swap to WPF and I had everything running in about 2 hours.
My end solution was to use a DataGrid with rowdetails that contain a DataGrid.
Related
Some sort of list will be displayed when the program runs
I want to make search with entering text on textedit. When I hit a button the gridview will be refreshed and show that the same values on entered text.
For example:
Firma Adı:ABC(User enters)
ABC123
ABCDEF
.
.
.
How can I make filter such that with using editValueChanged?
Thank you..
DevExpress grid offers this functionality out of the box.
You just need to display the AutoFilter row:
either programmatically using gridView.OptionsView.ShowAutoFilterRow
property
or as an end user by right clicking on the columns label area and
selecting the relevant menu entry
In addition to #GeorgeT's suggesion (which is very good, by the way -- the AutoFilter row is a crowd pleaser), one other thought.
Dev express has a control that does exactly what you appear to be attempting. It's called the "Find Panel." You can have it show up at design time from the OptionsFind properties of the gridView, and you can also have it show up at runtime via:
gridView1.ShowFindPanel();
I suspect you will find this is far better than anything you can program by hand... and with one (or zero) line(s) of code!
I have a data grid displaying results from a sql database. What I want to do is make it so that when I double click on a cell in the datagrid, a new window appears where that cell can be edited. I also would like to have all the info for that cell to be autogenerated into editable fields when the cell is double clicked. Any help or links to tutorials is appreciated. Thanks.
Try this DataGridView.CellDoubleClick Event
Did you consider using data binding? Simply put, you can bind your items list to DataGrid, and current item (eg. selected/double clicked) to your edit form's controls (TextBox, Label and whatever else you might have there).
Here are good starting points for windows forms: #1, #2. They cover problem you're facing. You can find data binding tutorials for ASP/WPF easily too, but especially first link covers entire concept pretty well.
Well it's not playing actually.
I have a database with about 200 list of items in it. I've used DataTable to fetch all the data in single connection.
Then created a windows button that creates new button for all the items.
It is OK and I was able to do it easily.
But I stuck over two things..
First is, I have limited space in my windows form, that's why I want to load only 30 buttons at first and then upon second click event, I want to load buttons for remaining 30 items and so on..
Second problem is, even if i managed to solve the first problem? How to arrange them in proper row/column?
Please help.
Grab an ordered list of records, split it to a list of "pages" (which is also a list of records) and use navigation buttons to change the context of current page.
Why don't you take a DataGridView with a BindingSource and a DataGridViewButtonColumn? With this as a starting point you can simply glue them together by calling:
myDataGridView.DataSource = myBindingSource;
myBindingSource.DataSource = myDataTable;
Update
Surely you can try to do the whole visualization on yourself by using a TableLayoutControl. But the DataGridView is a control that is specialized to visualize data in a data grid (hence the name of it).
The grid view is a very complex control, but it has a lot of nice features which make your results looking more professional by simply configuring some properties of it. For example simply set the property AutoSizeColumnsMode to Fill to simply avoid horizontal scroll bars and set the Column.AutoSizeMode of some columns to e.g. DisplayedCells to enforce which columns should be wrapped, etc.
Also there are a lot of features regarding to data validation, formatting, etc. So i think even if the step-in hurdle is a little higher you got a much better visualization then trying to do all this stuff manually by taking a TableLayoutPanel. Last but not least there are lots of examples about how to use the specific properties within the MSDN and if you get really stuck just search for the problem here on SO or on the web and if you don't find a proper solution just ask a question here on SO.
I have a forms application, showing results of several DataTables into several DataGridViews, each appearing in a different tab of an application.
I've noticed weird behavior when I reload the data (a single button invokes filling all DGVs from the matching DTs): DGVs with a lot of rows (which require vertical scrolling) which are not shown (only one is shown since they are in a tab control) don't have their scroll bars after the data fetch. But a window resize will show the scroll bars though...
I've tried forcing a dgv.Refresh() on each DGV after the dgv.DataSource = dt, but no luck.
Any input will be appreciated.
Cheers!
Maybe this after populating it?
dgv.ScrollBars = ScrollBars.Vertical;
Hope it helps, if not, could you show us how you're populating them?
Thanks.
My situation sounds pretty much identical to yours. I was having this same issue and found out it was because I was disabling and enabling the tabs in a background thread. Once I moved the calls to disable and enable the tabs to the main thread the scrollbars behaved normally.
I have a slightly similar issue, but maybe this may help in sparking an idea for you. For me, it appears to be something to do with the way my controls are docked. I found a rather convoluted solution which in short, says to add a new panel, and re-position the controls again on top of that panel. Since i found that re-sizing the form after all my controls appears to bring back the scroll bars, I just added a me.width = me.width+1 as my last statement to my form_load event.
I have 2 questions concerning C#.
1) I have a dropdown menu with several items in them. They are clickable, but when I click one, the older clicked one stays selected. Click another and the 2 original ones stay selected, and so on. I don't want this. What I want is that when I click one of the dropdownitems, that one is that selected one and the others are not.
2) I have a listview items on a winform. I loaded some string elements into it from a file. Now what I want to do is to be able to edit those strings and even add strings, just by clicking on the rows in which the data goes.
I've checked google and MSDN for these problems, but nothing helps, so I turn here.
2) The ListView does not support that type of action. You can roll your own (pain in the #$$), or perhaps a DataGrid would be better suited to your purpose.
EDIT:
This link may help
This one too
For #1 I'm a little confused. If the DropDownStyle isn't set to simple something strange is occuring. It's not much but maybe you could try recreating the control.
For #2 the easiest solution I can think of is to set a TextBox to be equal to the selected text value from your listview. After that write a little function to update the selected index of the listview with the edited text from the listview.
Please comment if you have any more information about #1.