WPF - datagridview options - c#

Need to represent a two column table. Maybe just for reference at this stage - or with the functionality that a double click presents a combobox essentially on that field with all the possible values that can be entered.
Is datagridview the best option for this in WPF or what else could I do to represent the data?
Cheers,

I'd say datagridview is the way to go. You can create your own custom columns. Here's a quick example:
http://www.code-magazine.com/Article.aspx?quickid=0707061

Or if you want to use something that's already available and pretty easy to use, check out SourceGrid. I've used it in WinForms and WPF applications, though the latter requires using WindowsFormsHost.
SourceGrid: http://sourcegrid.codeplex.com/

Related

How to show set of results returned by stored procedure in windows Form Application?

I am new to the Windows application.I will return a set of result from a stored procedure by accepting two date ranges. How will i show those results in windows Form application?
If i can use Data Grid view controls then its not looking good . Is there any other controls i can use or Is there any other way to show those results?
Thanks in Advance.
The best way to show this type of data would be to use datatables. If you dont like the default grid, try Infragistics controls, they look much nicer and cleaner than the built in grids. I'm sure there are plenty of other similar controls you can download, it just takes a little research...
Plus if you dont want the user to add or edit your grid, change the read only property of the grid to true.

Delphi equivalent of C#'s DataGridView

Is there any real equivalent of C#'s DataGridView in Delphi?
I have tried
TStringGrid
But the scrollbar is either invisible when all the items are visible, or it is the smallest scrollbar possible no matter how little the items are overflowed and only updates when the scrollbar is released, not when it is being dragged
Also, if you have one fixed row, you have to have at least one (empty) row besides that, which is inconvenient and unsightly
TDBGrid
But I can't seem to figure out how to add items programmatically (and I don't think it's meant to do that anyway). If I could do that, TDBGrid would be fine for me to use.
So what is the Delphi equivalent of C#'s DataGridView that doesn't have the problems listed above?
The DataGridView is a very flexible control which can work in bound and unbound modes, in the Delphi side you must choose bewteen 2 kinds of controls, for example if the content of the control can be edited directly (unbound) you can choose a component like a TStringGrid or in bound mode which in delphi is called data-aware you must choose something like a dbgrid, in this last case you edit the dataset asociated to the control and the control reflect the content of the dataset. Using this last scenario. you have several options about the dataset component to choose maybe the most flexible is the TClientDataSet. if you want learn more about this topic check these links
Understanding datasets Index
Types of Datasets
Opening and Closing Datasets
Modifying Data
Note : in the last version of Delphi (XE2) a new concept was introduced called LiveBindings, which introduces big changes in how you can bind a object or component to a collection or another component.
I would recommend you to check DevExpress.com QuantumGrid - it works both in Bound and Unvound mode

Create a custom Data Grid from Silverlight

I'm watching at this page:
http://leeontech.wordpress.com/2010/02/01/summary-row-in-datagrid/
But they're using silverlight. I'm trying to create that user control to use it in a WPF C# application. I mean, not using Silverlight. But I can't find the namespaces: GroupHeader
I'm having a hard time with this. Thanks in advance.
Okay listen, you can totally do this, and in some scenarios I even recommend it.
Using a CollectionViewSource you can easily group your data. In the HeaderTemplate you can even use an Expander (or make your own) and get the animation you might be wanting. Here's a link to a sample of this: http://jerrytech.blogspot.com/2010/06/wpf-data-presentation-step-by-step.html
Using an ItemsControl, you can easily present your groups and details. In the ItemTemplate you can use styles make this look like a grid (if that is really what you want). You can also shift the style based on the type if your collection has more than one type of object in it (eat that datagrid!).
You can wire up your column headers (which will really be custom objects, right?) and handle all the sorting and stuff like that. They will look just right! Not like datagrid WinForm column headers!
Here's what's hard (not impossible, but more coding).
User-resizable columns.
User-rearrangable columns.
New record using bottom, empty row.
Paste from Excel (doesn't work right in datagrid either).
Select Row, highlight Column header.
That's it.
In lots of situations, this is really nice.
For the most part, I cannot stand the datagrid. Too restricting on UX.
I don't think you're not going to be able to get a silverlight control working in WPF.
Adding a footer row to the WPF datagrid is something a lot of people have complained about; it's ridiculous that it wasn't included out of the box.
See this thread from MSDN
Having been through this myself, your best bet will probably be to bite the bullet and use a third party control. It sucks, I know.

How do I display a DataGridView within a cell of another datagridview in C# forms app?

How do I display a DataGridView within a cell of another datagridview in C# forms app?
How would I have to handle Sorting & value changed if this possible?
That is the only way I can display data to make some sense.. Think of it like I have a task column and dates column. Under the dates column I have a list of things to be done. These date columns are dynamic & there might be multiple date columns
That sounds like a difficult interface to use, have you considered some kind of tree control?
If you're determined to use data grid views, look at customizing data grid view columns and cells. You need to declare custom subclasses for the column and cell behaviour that you want. I don't know if it's possible to do what you want, but that's where I would start.
This is a suggestion since what your asking I do not think is possible with the built in DGV of .NET.
Using custom controls made by professional companies that provides a DataGrid with the capability of hierarchical data. For example a row can be expanded to show multiple entries (the multiple entries can be an entirely different table containing completely different columns even). Here are a few options that you can check out.
Infragistics WinGrid
Component One
There are a few other places/companies that make great .NET component packages that provide added features to the existing .NET components.
http://blogs.msdn.com/markrideout/archive/2006/01/08/510700.aspx
Found a link where hierarchichal datagrid is implemented.
Now, I have to either modify the control, or settle for hierarchichal gridview!
Hope this helps someone. Will update later

How to implement sorting in a listview while maintaining neighboring columns?

I have a ListView that has several columns.
One of them contains "Names", the other contains "Amount". I would like to allow the user to click the Names column in the listview and have it sort alphabetically and also allow the user to click the "Amount" and have it sort numerically (higher/lower - lower/higher).
What is the best way to implement this?
It is partially implemented but not completely. Microsoft have a description of how to approach this problem at http://support.microsoft.com/kb/319401.
To solve this, I wrote my own ListViewItemComparer which implemented the IComparer interface. Then, based on whether the column was numeric or string, I did the appropriate comparison.
ObjectListView (an open source wrapper around .NET WinForms ListView) does exactly this for you automatically.

Categories

Resources