Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Search as you type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 14 Jan 2008 23:59 GMT
Is there any known implementation of search as you type (in a db) in c#. Say
for argument sake, as I type in the 1st name the number of names in my
combobox decrease.
Signature

L. A. Jones

Michael C - 15 Jan 2008 00:23 GMT
> Is there any known implementation of search as you type (in a db) in c#.
> Say
> for argument sake, as I type in the 1st name the number of names in my
> combobox decrease.

You need to implement this yourself. It's not difficult

SELECT * FROM People WHERE FirstName LIKE abc%

Michael
Dave - 15 Jan 2008 00:31 GMT
What event I would need to attach this code to?
Signature

L. A. Jones

> > Is there any known implementation of search as you type (in a db) in c#.
> > Say
[quoted text clipped - 6 lines]
>
> Michael
Michael C - 15 Jan 2008 00:36 GMT
> What event I would need to attach this code to?

The change event for the textbox. Where are you getting the list of names
from? I was assuming a database which might not be correct.

Michael
Peter Bromberg [C# MVP] - 15 Jan 2008 12:29 GMT
KeyUp of the TextBox would be a good candidate.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com 

> What event I would need to attach this code to?
>
[quoted text clipped - 8 lines]
> >
> > Michael
Chris Shepherd - 15 Jan 2008 12:42 GMT
> KeyUp of the TextBox would be a good candidate.
> -- Peter
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> MetaFinder: http://www.blogmetafinder.com 

Isn't there a way to bind to a Data Source for autocompletion?

Chris.
RobinS - 18 Jan 2008 07:27 GMT
>> KeyUp of the TextBox would be a good candidate.
>> -- Peter
[quoted text clipped - 5 lines]
>
> Chris.

Yes, there is. It is outlined brilliantly in Brian Noyes' DataBinding book.
Let me know if you want more info, and I'll dig it up and post the code
example.  (Awesome book, by the way, worth the $ for the datagridview stuff
alone.)

RobinS.
GoldMail, Inc.
Andrus - 18 Jan 2008 09:46 GMT
> Yes, there is. It is outlined brilliantly in Brian Noyes' DataBinding
> book. Let me know if you want more info, and I'll dig it up and post the
> code example.  (Awesome book, by the way, worth the $ for the datagridview
> stuff alone.)

RobinS,

can you post sample ?
I'm very interested about it.
I have tried to use AutoComple in Virtual DataGridView  without success.
Mostly Autocomplete menu does not appear. Sometimes it appers, no idea which
controls this.

I'm interested on using DataGridView Virtual mode. Does this book cover
virtual mode or only as its title says, Databindig ?

Andrus.
RobinS - 24 Jan 2008 07:16 GMT
>> Yes, there is. It is outlined brilliantly in Brian Noyes' DataBinding
>> book. Let me know if you want more info, and I'll dig it up and post the
[quoted text clipped - 13 lines]
>
> Andrus.

Yes, the book does cover using the DGV in virtual mode. I will post either
the code for the AutoComplete (I'm using it for one of my comboboxes), or a
link where you can find it, this weekend.

RobinS.
Andrus - 24 Jan 2008 15:57 GMT
> Yes, the book does cover using the DGV in virtual mode. I will post either
> the code for the AutoComplete (I'm using it for one of my comboboxes), or
> a link where you can find it, this weekend.

RobinS,

thank you.
Will this code allow to use AutoComplete in a Combobox placed in Virtual
Mode DataGridview ?
Will autocomplete work OK overv low speed internet ?

Andrus.
RobinS - 25 Jan 2008 07:45 GMT
I don't know why not. Using AutoComplete involves keeping a local copy of
the table. I'll post it this weekend.

RobinS.
GoldMail, Inc.
-----------
>> Yes, the book does cover using the DGV in virtual mode. I will post
>> either the code for the AutoComplete (I'm using it for one of my
[quoted text clipped - 8 lines]
>
> Andrus.
RobinS - 27 Jan 2008 19:53 GMT
Here's the example of auto-complete. This example is for a combobox that
holds a list of fonts available. So I have the data table that is bound to
the combobox for the user's selection, and a collection of entries for the
auto-completion. I would think this would work for a textbox; if it doesn't,
post back and I'll go pull out Brian's book. I'm sure he has an example for
a textbox.

-------------------------------------

//variable checked in the selectedIndexChanged event
//  to suppress the event when the combobox
//  is being loaded
private bool m_loading;

//table of fonts
private DataTable dtFonts;

//collection to use for auto-completion of the font names
private AutoCompleteStringCollection m_Fonts;

private void LoadFontComboBox()
{
   m_Loading = true;
   //Set up datatable to bind to the combobox
   //  so you can use autocomplete.
   dtFonts = new DataTable();
   dtFonts.Columns.Add(new DataColumn("fontName"));

   m_Fonts = new AutoCompleteStringCollection();
   InstalledFontCollection m_allFonts = new InstalledFontCollection();
   foreach (FontFamily oneFamily in m_allFonts.Families)
   {
      if (oneFamily.IsStyleAvailable(FontStyle.Regular))
       {
           dtFonts.Rows.Add(oneFamily.Name);
           m_Fonts.Add(oneFamily.Name);
       }
   }
   FontFamilyComboBox.AutoCompleteCustomSource = m_Fonts;
   FontFamilyComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
   FontFamilyComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;

   //databind the combobox
   FontFamilyComboBox.DataSource = dtFonts;
   FontFamilyComboBox.DisplayMember = "fontName";
   FontFamilyComboBox.ValueMember = "fontName";

   m_Loading = false;
}

-----------------------
RobinS.
GoldMail, Inc.
------------------------------------------------------------

>I don't know why not. Using AutoComplete involves keeping a local copy of
>the table. I'll post it this weekend.
[quoted text clipped - 14 lines]
>>
>> Andrus.
Andrus - 28 Jan 2008 15:16 GMT
> Here's the example of auto-complete.

Thank you.
I have the following requirements:

1. Combobox dropdown list must display more than one column, e.q product
code and product name.
2.  Combobox dropdown list must be virtual (like DataGridView in virtual
mode).
(I have lookup table which can contain up to 500000 rows. So I think that it
is reasonable to show only records which are currently visible in screen).

Any sode sample which implements this? How to create
DrataGridview in virtual mode when user opens dropdown list ? Is it
reasonable to create form containing grid from Combobox dropdown event ?

DaisyCombo for .NET  from http://www.springsys.com seems to implement
requirement (1)

Andrus.
RobinS - 30 Jan 2008 06:52 GMT
>> Here's the example of auto-complete.
>
[quoted text clipped - 17 lines]
>
> Andrus.

I don't know offhand of a way to do this. Maybe you should just buy Brian's
book and see if it helps. I haven't worked with virtual grids, I just know
he has a decent chapter on it.

As for the combobox problem, I would probably implement some kind of search
button rather than using a dropdown box.

Good luck.
RobinS.
Andrus - 30 Jan 2008 10:38 GMT
>    FontFamilyComboBox.AutoCompleteCustomSource = m_Fonts;
>    FontFamilyComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
>    FontFamilyComboBox.AutoCompleteSource =
> AutoCompleteSource.CustomSource;

Why you do'nt use List as  AutoCompleteSource ?
Why you are messing with custom source ?
Using List This makes code simpler.

Andrus.
RobinS - 24 Feb 2008 18:29 GMT
>>    FontFamilyComboBox.AutoCompleteCustomSource = m_Fonts;
>>    FontFamilyComboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
[quoted text clipped - 6 lines]
>
> Andrus.

I wanted to provide the list of values for the auto-complete myself, so I
have to set AutoCompleteSource to CustomSource, and provide the
AutoCompleteStringCollection (m_Fonts) to use as the source.

Setting the AutoCompleteMode to SuggestAppend means that as the users type,
the dropdown list will display matches and append any missing letters for
the selected item when the user tabs out of the control.

This is from an example in Brian Noyes' Data Binding book, and it works
beautifully for me. As far as I know (I haven't tried it), you have to bind
to an AutoCompleteStringCollection to get it to work, not a List<T>.

RobinS.
GoldMail, Inc.
Michael C - 15 Jan 2008 23:27 GMT
> KeyUp of the TextBox would be a good candidate.

That's not really a good way to do it because they could change the text in
the textbox without using the keyboard. Changed event is probably better.

Michael

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.