c# - search listview items using textbox - c#

I am working on a project (simple phone book) for personal use.
Here you can take a look how it looks like:
IMAGE: http://s24.postimg.org/3qlicrcdx/Kruzeri.png
I am just about to finish it, but first I have to configure search bar to work properly. I would like it to find the contact I have entered in the textBox7. Ideally, first of all I would have to enter contact's name and then press the search button located right by the textbox. Then, it should select the contact I was searching for.
I have tried to solve this in numerous ways but with no success.
Does anyone have any idea how can I do this?
If needed, I have uploaded the whole code here where you can take a look at it:
LINK: http://www.sendspace.com/file/qa8rnq

If you use binding to fill your listbox, then you can just filter your list. For example:
element.ItemsSource = contactlist.Where(x => x.Name.Contains("SearchName")).

Have you read on regular expressions (RegEx)? That way you wouldn't need to write the exact name.
Plus, you should start naming your controls properly. Instead of textBox7, name it something like txtSearch. Using the prefix for the control "type".
Button: btnDoStuff
Textbox: txtDoStuff
etc..

Related

Refer to Ranorex repository elements dynamically

I have the following issue.
I'd like to refer to some repository elements dynamically.
For example, I have a button. Let's say it is a delete button.
It's name is constructed like this:
suppose I want to delete an element called "Joe"
In this case the delete button is called in Spy:
Joe.DeleteButton
In case of Bill, it is called
Bill.DeleteButton
If I want to implement a click on it I'd like to use a statement like this:
repo.Joe.DeleteButton.Cklick();
repo.Bill.DeleteButton.Cklick();
But the name is determined during runtime.
Can I set, construct this repo...  statement dynamically or is there a way to refer to it dynamically (during runtime)?
If Joe and Bill have identical type and located on some repo container you can find them like this
Ranorex.Adapter namesContainer = repo.NamesContainer.Self;
List<*Names_Type*> namesList = namesContainer.FindChildren<*Names_Type*>();
after that, each name can be clicked in that way
namesList[1].DeleteButton.Click();
For me to give a complete answer, I would need to know the XPath of both the delete buttons.
For example, if Joe and Bill are both forms and they both contain the delete button, the XPath syntax of the repo items could be something like this:
Joe Delete button = /form[#title='Joe']/button[#accessiblename='Delete']
Bill Delete button = /form[#title='Bill']/button[#accessiblename='Delete']
If you only wan't to click the delete button, regardless of the form name, simply change the XPath syntax to this:
Any Delete button = /form/button[#accessiblename='Delete']
You could add #processname to ensure it is the delete button of your app, or use anything else unique to your app under test.
In your particular issue, the Ranorex Spy is your best friend.
If you wan't to know more about XPath, I recommened watching Ranorex screencasts (really worth your time):
Ranorex Screen casts
There is also valuable information about XPaths in the following article:
Ranorex XPath tips and tricks
Hope this helps!

Textbox similar to Facebook or Stack Exchange's ones for websites

I'm pretty sure you all know what I'm referring to. It's like a textarea, and lets you enter stuff, and a little slide up menu will appear (kind of like an intellisense thing - displaying different words that it thinks you're going to type), and when u click it, or hit enter, it creates a little box inside the textarea with that word inside it. I need to find one of these (or make it myself), and I also need to grab those words entered and to some data stuff in Javascript before inserting them into the database. The "textarea" thing I'm talking about, incase I've got you completely lost, looks something like this:
Does anyone know if there are libraries/plugins etc that are available? Any help will be much appreciated!
Thank you :)
The correct term for it is a tag input. Google has lots of results for them.
Here's one I've used before: http://levycarneiro.com/projects/tag-it/example.html
Facebook style Tag input
AutoComplete Examples
this is not a textarea or input box, Contenteditable allows you to do this.
<div contenteditable="true"><span class="tag">tag1</span></div>
just like an input box you can write in a conteneditable div.

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.

How To Implement Search Option To DataGridView?

Lasttime my question may not be clear.So I comeback with same clarification to get the answer.
I develop one small Windows Application.
In C# coding time while I press Ctrl+F then I can able to see Find Window.
Similarly I want to have a serch to my DataGridView, and its DataSource is MyTable1. When the user presses Ctrl+F then I would like to do search and locate on Particular Row-Column in DGV's DataSource column.
Is it possible? Or any other way?
Thanks For Ideas
Here's a link with a simple sample of DataGrid search and highlight.
the data table has a defualtview property, you can use the filter property to apply the search. its like sql but only with the part that comes after the where

List of Strings to Links

i was wondering if it is possible in c# to set to a text box a list of strings that are clickable links? at the moment i can set the text box like this
txtBox.Lines = values.ToArray();
ideally though i would like them as links if possible? maybe link labels or something?
(I'm assuming you're using Windows Forms; the answer for WPF/Silverlight may be slightly different.)
A textbox just contains text - it's not "rich" enough to have links.
If you want a list you might want to consider using a ListBox of some description - or possibly a RichTextBox; I haven't tried creating links in a RichTextBox, so I don't know whether it's possible.
Of course, you haven't specified what you want to happen when the user clicks on the links, either...
Use RichTextBox and check this - http://www.codeproject.com/KB/edit/RichTextBoxLinks.aspx
You can try using Windows.Forms.Controls.LinkLabel. It allows storing multiple links along with the text in it.

Categories

Resources