Develop Search Control that can accept multiple search texts in WPF [duplicate] - wpf

This question already has answers here:
How can I create a tagging control similar to evernote in wpf?
(2 answers)
Closed 4 years ago.
I am working on a project that requires to search records by multiple customers, I an easily do that by making CheckList box but that will look pity, I've one example which I am trying to create in WPF, upto this point I am only able to do that to auto populate matching values but I want it to be like following.
If There is any control which can help me to achieve this like Searching for Customer A and Customer B in the manner shown in Screen shot.

It's a composite control. You can develop it by creating an UserControl (preferred) or writing a CustomControl on WPF.
It's depends on your time limitations. Finding an Open-source solution is a fast and easy way. but it must fill your expectations.
Most important part of developing such a Control is to decompose the complex control in some known controls.
I see a WrapPanel as a Container for this control and a main TextBox (with AutoCompletion) into it. and there are some Button which are created by an event.
for example you pressed the Space Button and the user control determined that It is time to add a Button as a Item into the main container (WrapPanel) and .... .

Related

How to add WPF UserControl onto a Form next to already existing form controls in a form designer? [duplicate]

This question already has answers here:
Put WPF control into a Windows Forms Form?
(3 answers)
.Net: How to use a WPF user control in a windows forms application?
(1 answer)
Closed 3 months ago.
I am interested in reusing old forms with form controls on it, not just any solution to add WPF control to a form. Why? Because this solution spares me from redesigning hundred forms that also have a WPF control on them.
Exception:
Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Component of type UserControl1 could not be created. Make sure the type implements IComponent and provides an appropriate public constructor. Appropriate constructors either take no parameters or take a single IContainer parameter.
To reproduce the problem: https://github.com/hovek/WpfApp1 and try adding UserControl1 to Form1, from the Toolbox.
VS Version 17.4.2
I guess it's not possible to design on a form: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.integration.elementhost?view=windowsdesktop-7.0

How to add columns dynamically to a TreeView

I'm fairly new to WPF and C#. I am developing a Tool, which reads data from a DB and puts it into a TreeView.
My class model looks like this:
class Developer //Contains a name, a list of categories and some additional info
class Category //Contains a name, a list of products and some additional info
class Product //Contains a name and some additional info
For now, the tool displays all the Names in a hierarchical manner. This is done via two HierarchicalDataTemplates and a DataTemplate for the leafs.
My question now is, if anyone has an idea how to add some simple columns to the TreeView which should display some double values. The problem is, that the number of additional info(double values) is set through user input. So, if the user wants to display a range of 3 months, I need the TreeView to add 6 columns. (column count = months * 2)
Or maybe someone knows a wpf custom control which suits my needs and works under vs10 and .NET4.0.
Thanks in Advance
The basic TreeView control doesn't support columns, there are specialized controls for this. Those controls are often called TreeList or TreeListView, as it includes the features of a tree and of a ListView. There are some commercial controls (the Telerik RadTreeListView comes to mind ) and there are some free versions floating around (one is in the Windows SDK itself, another one can be found here).
I've used none of them, so I can't tell which one is best suited for your problems, but I would give the last one a try, as it looks as it would solve them.

Designing a silverlight dashboard with mef - is it possible? (with dynamic loading of xaps)

I am just trying to wrap my head around MEF.
And as I am really going to love it ( I guess ) I started my first sample project and immediatly stumbled into a big problem and now I am asking myself if I can use MEF for my scenario at all and that is the following:
Imagine that one got some kind of dashboard with, let's say, five regions and above each region there are two comboboxes. The values in the first combobox represent different possible views (for example, chartControl, tableControl, pictureControl, ...) and the values of the second combobox represents the different data sources for the currently selected control.
As the controls are very big in size one wants to download them as needed.
If the user selects one comboboxitem the corresponding control xap should be loaded and displayed in this specific region. If the user selectes another control in the same combobox the control should be removed from the visualtree and the next control should be downloaded and displayed. If the user changes the selection in a different combobox the corresponding control should be loaded again only in this specific region, with perhaps different data.
And to make it a little more interesting - as this is some kind of dashboard one can change the layout from five regions to - for example - ten regions.
I've seen the video "MVVM with MEF in Silverlight Video Tutorial Part 2: Plugins and Metadata" ( http://csharperimage.jeremylikness.com/2010/03/mvvm-with-mef-in-silverlight-video_09.html ) but he is using an ItemsControl and is working with Visibility and he only got ONE region. So I think that this technique is not working for me...
Puh, I hope I could make myself clear!
Thanks a lot for any piece of information!!!
Greetings,
Tim.
Glenn Block has a series about using MEF to write a Silverlight Dashboard: http://codebetter.com/blogs/glenn.block/archive/2009/11/30/building-the-hello-mef-dashboard-in-silverlight-4-part-i.aspx

WinForms - How do I create a table using a custom control for each row?

I want to create a table representing data I have, but I want each row to have a custom display. I have developed a little custom control that represents a row and has a few items in it (text box, check box, progress bar), however how do I now in the main form create multiple instances of this for the data I have?
e.g. is there a winforms control I can use to do this? or do I have to take a panel or something and programmatically do it?
I do need to somehow take responses back. So if someone clicks on the button in the 4th row say then I'll need to be able to tell which row it was from.
As an aside would then be a way to BIND the above mentioned visualization of my data to the data itself, say housed in an Array?
thanks
I see two options here:
You can use a DataRepeater. This control can be found in the Microsoft Visual Basic Powerpack. It allows you to place controls on a template which gets copied for each item in the databound collection.
You can create a custom control and manually place one instance of it for each item in a collection, re-creating databinding for the controls in it. This requires you to either expose the controls inside publicly or as properties of the user control.
However, above options are mostly useful for non-tabular data. If your layout is strictly tabular (i. e. rectangular cells in a grid) then you can create a custom DataGridViewCell which takes some time to understand but not too much code. Putting a progress bar into such a cell shouldn't prove too difficult.

Complex .Net 2.0 Windows Forms control: where to start?

In order to make a convenient UI for an .Net 2.0 Winforms application I am working on, I have need for a control that I'm pretty sure goes beyond the "out of the box" behavior of any standard control. A mock-up of what I'm trying to achieve follows:
Mock up http://www.claware.com/images/temp/mockup.png
Essentially, this part of the application attempts to parse words into syllables from tribal languages (no dictionary to refer to; any and all unicode characters are possible.) By the time the user gets this far, he has already defined the vowels / consonants in his language and some other configuration. There is then an iterative process of (1) the application guesses which syllables exist in the language based on some rules, (2) the user refines the guesses, selecting the correct parsings or manually parsing a word, (3) the application "learns" from the user's feedback and makes smarter guesses, (4) repeat until the data is "good enough" to move on.
The control needs to present each word (the grey headers), then all the syllable break guesses (the white areas with dots separating the parts of words.) There is also a way to manually enter a parsing, which will display a text area and save button (at the bottom of the mockup.) When the user hovers over a guess, the background changes and "accept / reject" buttons appear. Clicking on the accept, or entering a manual parsing, removes the entire word from the list. Clicking the reject button removes just that item.
I'm by no means 100% sold on the formatting I have above, but I think you can get a general idea of the types of formatting and functional control I need. The control will also scroll vertically--there may be thousands of words initially.
My question for you experienced WinForms developers is: where to start? I would really, really like to stay within the .Net core framework and extend an existing control as opposed to a third-party control. (At the risk of starting a religious war: yes, I suffer from NIH-syndrome, but it's a conscious decision based on a lot of quick-fix solutions but long-term problems with 3rd party controls.) Where can I get the most "bang for my bucK" and the least reinventing the wheel? ListView? ListBox? ScrollableControl? Do I need to go all the way back to Control and paint everything manually? I appreciate any help that could be provided!
[Edit] Thanks everyone for the ideas. It seems like the most elegant solution for my purposes is to create a custom control consisting of a FlowLayoutPanel and a VScrollBar. The FlowLayoutPanel can contain instances of the custom controls used for each word. But the FlowLayoutPanel is virtual, i.e. it only contains those instances which are visible (and some "just out of scroll"). The VScrollBar events determine what needs to be loaded. A bit of code to write, but isn't too bad and seems to work well.
I would look at the TableLayoutPanel and FlowLayoutPanel controls. These will let you organize a series of controls with moderate ease in a vertical fashion. I would then create a UserControl that consists of a label and 2 buttons. The UserControl will expose properties like Text and events that are exposed for the button clicks.. For each entry in the list, you will create an instance of the UserControl, assign the text value, and handle the click events. The instance will be placed in the Table/Flow panel in the correct order. Both of those layout panels do allow for inserting items between other items so you can add/remove items from the list dynamically.
Edit:
Given the length of what you are trying to render, I would consider using the DataGridView and do some custom rendering to make it perform how you want it to work. Using the rendering events of the DGV you can merge columns, change background colors (like highlighting the dark gray lines), turn on/off the buttons, and handle changing the grid into edit mode for your rows to allow modification or inserting of new values. This method would easily handle large datasets and you could bind directly to them very easily.
Well, this certainly looks like a candidate for a custom component that you should be creating yourself. You can create this using standard .Net drawing commands along with a text-box, and a regular button control.
Now you want to find out where to start.
Create a Windows Forms Control Library project.
Drop in the textbox and the button control.
The panel drawing code should preferably be done by code. This can be done using the regular GDI+ commands.
Edit:
Here's another idea, and one that I've practically used in my own project with great success.
You could use a web-browser control in the app, and show your data as html. You could update the source of the web-browser control based on the input in the textbox, and clicking on the links in the web browser control will give you the event that you can trap to do some action. Your CSS will work.
I used this technique to build the 'desktop' in an app I made called 'Correct Accounting Software'. People loved the desktop so much that it is one of the best loved features of the app.
Here's how I would do it:
Create a custom control. In this custom control, have a ListBox atop a LinkButton, and when the LinkButton is clicked you can make it give way to a TextBox. The ListBoxes will have the top row unselectable... you can probably get the rest from there. When you get your list of words, fill a Scrollable of some kind with one control for each word:
(foreach String word in words){
myScrollable.add(new MyComponent(word));
}
From there, I'm not sure what you want to do with the boxes or the data, but that's my initial idea on the UI setup.
Use the WebBrowser control and generate the HTML markup into it using DocumentStream or DocumentText.

Resources