1

I am working on C# winform vs2008 project. Requirement is to show line level details into grid and grid one text box cloumn user will type the text and it should populate the autocomplete text. Autocomplete search should based on one column only, but need to show additional one column to user. Exampe : Name and Phone number. user will search based on Name only additional column phone should display purpose.

I have following query :

1) Database is large, is there any free autocomplete 3 party tool available.? 2) How can i show muliple columns in autocomplete.

Please let me know, how i can show multiple columns in autocomplete.

I am stuck here.. please help me out..

Thanks and Regards Ram

  • This is not easy. I think you have to create your custom DropDown list and implement all the event handlers. wow, so much work. – King King Jun 10 '13 at 09:29
  • Hi, Thanks for the reply. Some way should be there, please give me some examples. Currently i can able to show one text collections in autocomplete using namecollections. I want to bind additional one column. If i use Combobox, how can i assign 2 columns. Please clarify. – user2470206 Jun 10 '13 at 11:43
  • Try with Combobox.. Use a `BindingList>` as its datasource, with the DisplayMember as the Value and ValueMember as the Key.. Define an override for ToString() of `YourClass` such that it would return a formatted string: "Name in 4 tab spaces PhoneNumber" It might not work if the ComboBox internally parses the string Value of its display member. – Ren Jun 10 '13 at 15:00

2 Answers2

0
public Class YourClass
{
    public string Name;
    {
       get;
       private set;
    }

    public string PhoneNo;
    {
       get;
       private set;
    }

    public override string ToString()
    {
       return String.Format("{0,-50} {1,-15}", this.Name, this.PhoneNumber);
    }
}

internal class YourForm : Form
{
    ComboBox YourComboBox = new Combobox();
    //Set the style of your combobox such that it looks like a text box

    BindingList<KeyValuePair<string, YourClass> bl = new Binding<string, YourClass>();


    //Query for the data to populate the BindingList
    //Lets say you put the UserId or ContactId of the person in the Key..        

    YourComboBox.DataSource = bl; 
    YourComboBox.DisplayMember = "Value";
    YourComboBox.ValueMember = "Key";     
}

Do what ever you are doing for autocomplete

There's no ready and elegant implementation for what you need. What I gave you would display the results like in a table..

Eg:-

  • Reese W 32
  • Pamela A 40

but with the name, taking about characters of space in what ever font the control renders..
(You will have to look at this answer in edit mode to see it)

If you want exactly what you need, you WILL have to use some available 3rd party controls or write one of your own. And as some one said, it's too much of code..

Ren
  • 437
  • 4
  • 17
  • Hi Venat Renuka, Thanks for your reply. My requirement is to show the additional columns (like 2 columns) not formating/adding string and show. Customer required to see two seperate columns (like grid example). Please assist. Thanks in advance.. – user2470206 Jun 11 '13 at 07:50
  • Hi, Thanks a lot for your reply. Client required to show in additional column only and including some color display. I want to write my own control. Could you please guide me how i have to start the flow. If you have any sample own contol codes, kindly post for me, this will be helpful for me.. please. Thanks. – user2470206 Jun 12 '13 at 05:09
  • Hi,I am planing to create my own autocomplete control (due to some limitations found in multiple column show, starting letters only can search, sorting issue etc.,). for that i am capturing result in autocomplete text box and fetch the string and display into listbox. For this i need quick way of searching. If i achive this i will add other columns in list box (only showing purpose) and colouring etc.. Because i want to enhance more future in my autocomplete and dont want to buy 3rd party controls.Please guid me whether i am going right way or not.. – user2470206 Jun 12 '13 at 08:50
  • My textchange event code is as below : foreach (String s in textBox2.AutoCompleteCustomSource) { if (s.Contains(textBox2.Text)) { listBox1.Items.Add(s); listBox1.Visible = true; } }... here i need faster seach, its taking too much time for example records 50000... please help me.. – user2470206 Jun 12 '13 at 08:51
0

There are third party components that can be used to support multiple column drop down, for example DevExpress's LookUpEdit, Infragistics's UltraCombo and Telerik's RadMultiColumnComboBox. You can change the filter then popup the dropdown when typing, but that is not going to beat the performance of Windows's autocomplete, which uses a second thread to enumerate candidates.

If you have that much data, auto-sizing the drop down columns and animation probably need to be disabled if your control library enables them by default.

Sheng Jiang 蒋晟
  • 15,125
  • 2
  • 28
  • 46
  • Hi friend, thanks for your reply.. if you know any code to show multiple columns on combobox that will be helpful to me instead 3rd party. My requirement is autocomplete is based on 1 column only, but i need to show other column seperately display purpose. I understand your message about performance. If i fix multi columns combo issue, i will go next step to check the performance from remote qurey. Please check and help me. Thanks a ton. – user2470206 Jun 11 '13 at 07:57
  • The combobox class is a wrapper of the win32 native control with the same name, which does not have multiple column support. You either need to buy a component or write one from scratch. – Sheng Jiang 蒋晟 Jun 11 '13 at 20:16
  • Hi, Understand. Thanks for you reply. Do you have any sample code for write our own controls, i wish to start my own control. Please post if you have.. thanks. – user2470206 Jun 12 '13 at 05:10
  • Check http://stackoverflow.com/questions/4899169/multi-column-combobox-controls-for-winforms – Sheng Jiang 蒋晟 Jun 12 '13 at 13:18
  • Hi Friend, thanks for the link.. this i have checked already good 3rd party controls. I wish to start develop my own control, becz requirement is more (multi column, different sortting and coluring etc). So please give me a start up links which i can proceed / start new control correct way.. please check and help.Thanks – user2470206 Jun 13 '13 at 13:21
  • The code project samples linked in the discussion have full source code you can use as reference – Sheng Jiang 蒋晟 Jun 13 '13 at 22:38
  • Thank friend.. checking that links.. again thanks for your help.. will let you know if any clarifications required.. – user2470206 Jun 16 '13 at 12:08