Custom WinForm ListBox with user-input content - c#

I have a need to provide as options multiple objects from a particular data set, and populate a list so that an end-user can select, none,some, all, or all + possibly missing data fields (user-input).
I originally planned to extend a System.Windows.Forms.ListView to include a whitespace item that contained a checkmark, then specially handle the case where a user had clicked this blank line item.
I would like the ability to remove these user-input line items if possible. I do not have to use a System.Windows.Forms.ListView, but its design seems to best-fit this particular use.
Is there a control with this functionality already , or an attribute of the System.Windows.Forms.ListView I have missed that may handle these situtations?
---Update---
ListBox is changed to System.Windows.Forms.ListView

DataGrid sounds like it would be a good fit; otherwise I'd suggest looking at 3rd party controls.

Related

WPF - what is the best way to bind data from a database to a checkbox control

I am struggling some time with checkbox control in WPF. What I am trying is to to make some kind of filter.
1. So first I need to fill the checkbox control with the database items
2. Second I need to check if anything is checked
3. Third if anything is checked I want to take those values and use them to search through the database
4. Should I use only checkbox control for this or should I put it in some container or a listBox?
I have find many topics here that are mentioning this stuff, but I couldn't manage to find the complete answer, only lot of parts that are not compatible with each other. I would really appreciate if someone explain to me how checkbox in WPF works.
If you have multiple values and you want to display multiple CheckBoxes, one for each of them, then you will need to use a ListBox and have the TemplateItem a CheckBox. This way your collection of items is bound to the ListBox, and for each item in the ListBox a CheckBox is shown.
So to get each of the values after there is an additional step if your doing MVVM and don't want to touch the UI. What you do is create a wrapper class that sits around your class and has a extra property for the IsChecked data. This way you can get the checked state without touching the UI.
I have an example of this on my blog:
Checked ListBox in WPF
To check which items are checked you just need a simple LINQ query. So if you use the example there from my blog then you should be able to do something like this:
var checkedCustomers = Customers.Where(w=>w.IsChecked).ToList();

Metro style: how to show filtering options for longlistbox in a proper way

I have a large collection of items with several parameters, so i'd like to give a user a possibility to have different filters: like order by time, by alphabet, or by categories.
How should i implement filter selection in Metro style? Should it be a menu items like this, but with "filter by alphabet" instead of "menuitem 1" ?
Edit:
Some more details: so, assume we have Movie items with 4 fields: name, year of release, genre and main actor's name. I'd like to allow user to set filtering by 1 of those 4 fields. Actually, it is not filtering or sorting, its more like categorizing.
Ok, i found this thing, looking quite nice.
Edit: though, be careful, it is not working the same as on the picture. At least, current version is not fading the screen, so other controls still would react on user input and Back button.
No way - the AppBar menu is not the way to go. For filtered content, you would normally use LongListSelector (both on WP7 and WP8). The filtering can be set by you when you group (or re-group) the items bound to the control - for the filter setter you could use any control (e.g. a auto-complete text input control or a ListPicker).

FindPanel DevExpress Component Too Slow

I need a search panel similar to the findpanel in devexpress. FindPanel is a bit slow: it searches all the visible columns and removes the not-fitting-the-description rows from the xtragrid. If you know a way to override these unwanted behaviors or another component that does the same job without the previous behaviors please do share. If not...
I need to create a panel, with one textedit, and two simplebuttons in it. And since I am going to use this same component with different xtragrids over and over again, I need to make it a standalone component, and be able to point towards the xtragrid from the properties window. As if its a standard component.
So how do I do that ? If you have an entire example project it would be perfect, but if not, I am just looking for some pointers.
Thank you...
There is a property to specify a list of columns for search by: ColumnViewOptionsFind.FindFilterColumns Property
You also can create a standalone user control with the public GridView property. This property allows you to select GridView instances in the designer. To apply the search expression programmatically, use the ColumnView.ApplyFindFilter Method

How to build a "word-by-word" autocomplete in WPF?

I already did some research and ended up with several autocomplete boxes which have one thing in common: they all match the whole expression which has been entered. Sometimes, they seem to be easily expandable, but at the end, they aren't.
However, I need a Textbox which allows the user to enter a word (e.g. "tag1"), displays a popup with some suggestions based on this single word, accept the suggestion with the return key and type in a new word (e.g "tag1 tag2") in the same textbox, with the popup popping up again. (I like the way CintaNotes handles this)
I need this for a tagging interface. It's often faster for the user to write the tags into a simple box, but sometimes, he needs assistance. This is what the autocomplete is for.
I've found some results, which don't work for my purpose (imho):
http://www.wpfpedia.com/item/details/743/wpf-autocomplete-textbox-control
http://www.codeproject.com/KB/WPF/WPF_Autocomplete.aspx
http://www.codeproject.com/KB/WPF/autocomplete_textbox.aspx
http://weblogs.thinktecture.com/cnagel/2011/01/autocomplete-textbox-with-wpf.html
Btw, I really like the way the Tag-Box for SO operates.
Does anyone have an idea? Is there a "out-of-the-box" - solution somewhere, which suits my needs but I didn't find? Or do I have to build one myself?
Thanks! :)
I think you mean a textbox which autocomplete for multiple words.
Like TokenizedTexbox on WPF Extended Toolkit.
this is the page: http://wpftoolkit.codeplex.com/wikipage?title=TokenizedTextBox&referringTitle=Home
Probably you would need to create your own Dictionary object of Key and Value pairs and hook that Dictionary to the textbox events and popup a suggestions dialog that displays the Value(s) from your Dictionary
Check this implementation out: http://code.google.com/p/kocontrols/downloads/list
You may inject your own Search algorithm and your own converter which converts the selected element to text, which you display in the TextBox. You will have to modify it slightly but I think that you might be able to solve your problem by basing your control on this implementation.
I never thought about this type of use case.
Can't you use different textboxes for the different tags? Something similar to how goole code does it?
If you have time, you can use the RichEditControl or TextBox and apply the same pattern used in Intellisense engine or Code Completation enabled editors: Hook the text changes events, Recogize context (last/current word) and display the options list on popup control. And optionally, on commit (detect acceptation or space key), apply the format to the word.

UI for creating invoices

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!

Categories

Resources