How to achieve multiple grids like the SQL server Results pane - c#

I'm having problems with my project once again :(
The front end is C#
I need to support multiline querying like MS SQL server and when these queries are executed, naturally there are going to be multiple result sets.
Getting the datatables respective to the results is not a problem, but how do i make it appear like its done in MS SQL server. One result set below the other and with a scroll bar?
Should i bind it to a datagrid? If so how can i bind multiple tables to a datagrid ? and will it generate the scrollbars and the columns automatically?
If i am not clear, please let me know and i'll try to be more clearer.
ps: If anyone knows how this can be done with the XtraGridControl in devexpress that would be awesome ! :D

you can set a panel with scroll bars on your form and add programatically number of datagrid depend of number of data source. Just add datagrid control to the defined panel.

The control you probably want is System.Windows.Forms.FlowLayoutPanel (see FlowLayoutPanel#msdn)
It is available from .NET v2 and greater.
flowLayoutPanel1.FlowDirection = FlowDirection.TopDown;
....
// for each result...
flowLayoutPanel1.Controls.Add(newGrid);
I have used it before to achieve a similar effect. I have not however tried to re-size the items within it, they were fixed in height (re-sized width-wise to fit the parent).
You should be able to create each XtraGridControl instance with the required data and add it to the controls as above.
PK :-)

SQL Management studio doesn't display all the results in a single grid unless it's a UNION query. Appending multiple grids to a single scrollable pane is the right way to do it, unless you want to break them off into individual tabs.

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.

DevExpress Xtra Reports Page Break Not Working

Working on a project, where I generate graphs dynamically using xtra reports of the dev express suit, and am not bidning the graph to a data source. When I use a datasource to produce labels to test them out, the
Detail.PageBreak = DevExpress.XtraReports.UI.PageBreak.AfterBand;
works. But if I am generating the labels without a data source, this doesn't work. Does anyone have a clue?
Source:forcing a conditional page break when a label text changes value
To accomplish this task you can either add a GroupFooter band and set the GroupFooter.PageBreak to AfterBand. or put a XRPageBreak control, handle the Detail.BeforePrint and adjust the visibility of the XRPageBreak as you need.
To get processing row you need to use the XtraReport.GetCurrentRow() method.
Please try this solution, and let us know the results.
You can force a page break on certain conditions. Reference link has an example at the bottom as attachment..
You can also use the Before_Print event to accomplish this task.
Hope this help..

winforms listview - make first column always visible?

I have an application (winforms, c#) that displays data in a Listview in a very usual way - the first row is headers, the first column in each row is header and the following sub-items is the data itself.
I want the first column (the headers columns) always visible and the horizontal scroll to affect the other columns only.
i don't think it is possible in winforms listview (am i wrong?). Hence, i'm thinking to split the listview to two listviews - one for headers and the second for data. In that case, i need to connect the vertical scroll bars - a task which i find to be harder than i've expected.
Am i taking a wrong path (e.g. would it be easier to use a different control)?
If not, any pointers on how to implement it?
Note: Winforms Listview has poor API (e.g. no scrolling event) and is known as buggy, so i'm looking a working sample rather than MSDN links...
Thanks
As already noted the DataGridView supports this behaviour, but nobody told how this will be done:
To enable this feature simply set the Frozen property of a column. Further informations can also be found in this How to: Freeze Columns in the Windows Forms DataGridView Control.
I think you have to try to use the DatagridView instead of the listbox. As far as I know, the DataGridView supports this.
Did you try using DataGridView instead?
Edit:
In case you run into problems with setting row headers text, take a look at this post (basically, you set row header text upon item being added to grid).

Playing with buttons in C#.net using visual-studio

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.

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

Categories

Resources