This is a migrated thread and some comments may be shown as answers.

How Could I remove the Duplicates in rad Autocompletetextbox

4 Answers 111 Views
CheckedDropDownList
This is a migrated thread and some comments may be shown as answers.
Bhushan
Top achievements
Rank 1
Bhushan asked on 19 Jul 2014, 06:14 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RadautocompleteDemo.Model;
using Telerik.WinControls.UI;
using Telerik.WinControls.Data;
using Telerik.WinControls;
namespace RadautocompleteDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();



            radAutoCompleteBox1.AutoCompleteDataSource = new Sample().ListGetSuggestions();
            radAutoCompleteBox1.AutoCompleteDisplayMember = "name";
            radAutoCompleteBox1.AutoCompleteValueMember = "id";



        }

        private void button1_Click(object sender, EventArgs e)
        {
            int i = radAutoCompleteBox1.MaxLength;
            int j = radAutoCompleteBox1.TextLength;

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.radAutoCompleteBox1.Items.CollectionChanged += new NotifyCollectionChangedEventHandler(Items_CollectionChanged);
        }
        List<Telerik.WinControls.UI.RadTokenizedTextItem> list = new List<RadTokenizedTextItem>();
       // HashSet<Telerik.WinControls.UI.RadTokenizedTextItem> HashSet = new HashSet<RadTokenizedTextItem>();
        void Items_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            RadTokenizedTextItemCollection items = sender as RadTokenizedTextItemCollection;
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                //list.so

                foreach (RadElement element in this.radAutoCompleteBox1.TextBoxElement.ViewElement.Children)
                {
                    TokenizedTextBlockElement token = element as TokenizedTextBlockElement;
                    if (token.Item == e.NewItems.SyncRoot)
                    {
                        MessageBox.Show("Item.already prepset");
                       //NotifyCollectionChangedAction.Remove;
                    }
                   
                }
                Int32 index = 0;
                for (int i = 0; i < e.NewItems.Count; i++)
                {
                    
                        list.Add((e.NewItems[i]) as RadTokenizedTextItem);
                    
                    //bool chekc = HasDuplicates((e.NewItems[i])as RadTokenizedTextItem);
                        list.Sort();
                       
                        while (index < list.Count - 1)
                        {
                            if (list[index] == list[index + 1])
                                list.RemoveAt(index);
                            else
                                index++;
                        }
                }
             

            }
        }

        private bool HasDuplicates(RadTokenizedTextItem radTokenizedTextItem)
        {
           // List<RadTokenizedTextItem> vals = new List<RadTokenizedTextItem>();
            bool returnValue = true;
            foreach (var s in list)
            {
               
                if (list.Contains(radTokenizedTextItem))
                {
                    returnValue = false;
                    break;
                }
               
            }


            return returnValue;
        }






    }
}


I am Trying to remove the duplicate values entered by user..if suppose user enters the duplicate values in the radAutocomplete textbox then i just want to give the messagebox that "Duplicate values are not allowed"and after giving this message i just want to remove the duplicate value entered by the user automaticaly..
I am new to this controls i tried to find out the events but i didnt get any...
so please give me the solution
Thaning You in advance

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Jul 2014, 03:04 PM
Hello Bhushan,

Thank you for writing.

Before getting to your question, we would like to check something related to your license. Your account shows no purchases and it seems that you have not downloaded the WinForms suite from our site. Since it is our policy to support users in good account standing, I would kindly ask you to give us more details on the license you are using:

- In case you have downloaded it from another site/account, please let us know so that we can update your account and provide you with proper support services; 

- In case you have obtained a copy of our controls through the company you work for, please ask the purchase holder to add you as a License Developer to the purchase. This will give you full access to the products your company has purchased, to our downloads section, and to our support ticketing system.

Additionally, all your questions will be reviewed according to the license you have. More information on License Developers you can find here: http://www.telerik.com/faq. I have moved your Forum post to our support ticketing system (which is private communication channel) to avoid sharing confidential information in the public Forums. You can find the ticket in Your Telerik Account.

As to the question at hand, your question has already been answered in the other thread you have opened. Please, see our answer there for more information.

Looking forward to your license information.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Zan
Top achievements
Rank 1
answered on 22 Dec 2017, 06:02 AM

Hello Telerik Team,

 

     

0
Zan
Top achievements
Rank 1
answered on 22 Dec 2017, 06:03 AM

I also need this requirement.

pls support.

0
Zan
Top achievements
Rank 1
answered on 23 Dec 2017, 03:17 AM

I have solved this requirement with RadChecked DropDownList.

Thank.

Tags
CheckedDropDownList
Asked by
Bhushan
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Zan
Top achievements
Rank 1
Share this question
or