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.
Related
For the last few weeks I've been building a product demo for work which includes a winform to enter new customer enquiry information. One of the form elements is a text box which, for the sake of ease, I haven't imposed any validation on so far. However, I now need to make it so that the user can only enter a valid location from an sql database table (containing around 15k streets).
I'm still quite new to C# programming. My first thought was that I should change my text box to a combobox but I seem to remember that when you click on a combobox all the options in the list appear before you've typed anything. Since our computers are slow and there's so many options, I don't really want to flood the screen so I was wondering if there was a way I could continue using my text box and onkeypress (probably the tab key) a dialogue pops up with all the closest matches from the list, prompting the user to select a valid option?
If not, is there a way to stop my combobox from showing the option list until prompted?
I would not think a combobox is not well suited for that many items.
The way I have approach this is to use a separate list view to show matches. You could probably put matches in a drop-down style borderless window, but I find that more complex and may be difficult to make the interaction work well.
I would just have the streets in a separate list view control and apply a filter to that.
Make sure the view is resizable, I find it very frustrating when working with old window controls where the list is tiny due to it being written for 640x480 screens, and does not allow resizeing.
Keep performance in mind, when searching with each key-press you might want to fetch all records and do the search in memory rather than making a sql query for each key.
i got a question regarding C#
I'm about making a program to hold all my daily tasks, and i need to show them in some kind of panel/list, Ive tryed with the gridview and it worked fine, but i don't want a "table" look, i rather want somekind of access database look, so it creates a new textbox/label maybe a panel with several informations - got any suggestions for this one? if it's possible in a easy way.
If you want just use WindowsForms, you can, for example, define a UserTaskControl:UserControl that holds unique set of controls you need for single entry.
Let's say you need for single entry to have Title, StartDate, EndDate, Description, so you can create a control with 4 TextBoxes or 2 TextBoxes and 2 Calendar controls (matter of design choice).
After define on main window TableLayoutPanel and at runtime add new instances of your UserTaskControl in the moment you need a new entry in your task list.
If you want to make things much better, consider of using WPF, as there you can use also UI Virtualization technique (just one example), which can make a difference in regard of WindowsForms, if you have too much entries in your list (too much is application specific measure, obviously). But in this case you need to learn WPF and learn to use it in a good way, which is a right thing to do IMHO, but depends on how much time you have.
Hope this helps.
A listview with checkboxes to check off when you've completed them? You can make the items editable or put in an "editing panel" to use to edit the values.
So you'd have:
[x] Get dressed
[x] Take out the garbage
[x] Make breakfast
[x] Ask ? on stackoverflow !
[ ] Implement solution
I did this one for work as a task tracker.
In my WPF application, I've got a screen with a tab control. Five of these tabs contain datagrids which need to display a large number of rows (at least 5000). The tables are bound to ObservableCollections of Part objects. Each row displays around 20 points of part data. My problem is that, after the user enters the information they require and generate the data, clicking on a tab causes the application to hang for 30-60 seconds. After this the datagrid finally loads, and with the right virtualization settings, they perform at an acceptable rate (not exactly fast, but not too slow). If I disable virtualization, the program uses up way too much memory, and the loading time isn't really affected.
The most offensive tables consist of about half a dozen template columns. Each template contains controls inside a stackpanel or a grid; basically each row is split into two, like a double-row. This layout is a requirement, and paging is probably not something that the customer is willing to accept.
This is the most important screen in my application and I'm pretty much at a loss about making this work. Is there anything I can do to speed up this process? Perhaps ObservableCollection is the wrong choice?
Can you please provide more insights...
Can you check how much time is spent in "generating" the 5 collections of 5000 rows each? (this is what I assume you are saying)
With virtulaization "on" what is the UI loading time "after" we assign the collection to the items source?
What happen if you bind "ItemsSource" to the respective datagrid only when the tabItem is actually Visible \ Selected?
Do you datagrids have default sort member path? Grouping? Filter Paths?
These are a few things I would target to start on the issue.
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.
Currently, I'm in the process of making a custom solution for invoicing. I have created multiple ways for customers to create their template (HTML, Word, LaTex) and get invoices according to their template. However, these invoices are party manually generated.
So, the process is:
Request to create a new invoice
An preliminary invoice is created
The user gets a chance to make changes (i.e. add, remove, change rows)
Create a pdf
Just to be clear, the preliminary invoice does not need to be formatted as the template is, but you should be able to add/remove/change rows and for every cell, indicate whether the value should be visible in the final result.
My problem is that i cannot find a suitable way to display the preliminary invoices. I tried a datagrid (default, telerik, devexpress), but it's too messy. Besides a datagrid, i have no idea what i can use.
What controls can i use best to have a nice and usable UI.
Please don't be like this:
alt text http://bitsandpieces.us/wp-content/uploads/2008/03/imagesapple-20google-20and-20you.png
A typical UI paradigm for this kind of thing is to view it as two separate problems: giving the user a way of viewing the elements that he can modify, and giving him the ability to modify any specific element. You use a list control (ListBox, ListView, maybe TreeView if the elements are organized hierarchically or need to be grouped into categories) to present the elements, and then when the user selects an element the program presents a tabular presentation of field names and editable value controls.
Basically, you're dividing the program's functionality into two categories: stuff that the user wants to do to rows (add, remove, re-order, select) and stuff that the user wants to do to the selected row's elements.
You can mush these two sets of functionality into one if you use a DataGridView, but as you've seen that gets pretty ugly if there's any complexity to the elements you're editing.
Two possible approaches to this: the property-sheet paradigm (select object, right-click, select "Properties", edit values in a modal dialog), or a paradigm where the window's split into two panels, with one being the rows and the other being the details of the currently selected row. There are lots of others.
What is your platform? Winforms? WPF?
What exactly did you dislike about using a datagrid for this? Part of the problem is that whether you like it or not, you're going to be coding a datagrid - you essentially described features of one. If at all possible try to use someone else's datagrid because it will save you a lot of work. Typically, 3rd party datagrids should be fairly customizable, and you should be able to make it look however you want - and take advantage of the built in sorting, editing, grouping, etc. Creating a datagrid-like control from scratch isn't easy and should be avoided if possible.
You don't have to have a plain giant datagrid - you can crate a custom control that displays the invoice formatted however you like, with a live datagrid appearing only where the invoice shows tabular data, formatted to appear as an integral part of the invoice itself.
I'm doing something similar, where the client can edit or even remove the line items for the invoice prior to sending it to the client.
The current app they run their business on is a WebForms Intranet application, so this is an extension to that. So they can add/remove/edit rows fairly easily.
But Egor is right. You're essentially talking about a datagrid no matter what you do. I take it you want something 'cleaner' and more intuitive?
Simplicity is difficult.
I would take a look at what is already out there, especially for invoices, and see how they are doing it.
Not sure how big your company is, but it never hurts to take advantage of the large company applications and user interfaces, the pour thousands/millions of dollars into user interface design and testing.
I would take a look at any of the following (most offer a free trial, or just try searching for screenshots):
www.freshbooks.com
www.invoicera.com
www.getcashboard.com
www.simplifythis.com
Just some ideas ... hope this helps!