How to Remove Duplicate Items in Dropdown List

2
7/10/13 how to remove dupl icate items in dr opdow n list? social.msdn.microsoft.com/Forum s/w ind ow s/e n-US/6 1e 81 66 7-7b 40 -4f4 2-ac c6-37 31f680fc8b/h ow -to-remove-duplicate-items-in-dropdo w n-list 1/2 Answered by: Top related threads how to remove duplicate items in dropdown list? Remove duplicate items from list How to merge items from List<List<int>> to List<int> and remove duplicates in LINQ query How do you remove a custom action item from the workflow Action dropdown list in SharePoint Designer? How to remove duplicate items form a listbox? Ask a question Quick Access Search related threads Search forum questions 13 5 3 JohnGrove's threads iew Profile 35,075 Points Lead Developer of an application designed o help troubleshoot anything mechanical hat is described with a schematic. Particularly intereste d in Process ptimization, .NET, Relational Database Design, CGM, Vector Graphics, Object- riented Techniques. I enjoy Judo, surfing, hiking, weight-lifting, running, and of ourse programming. JohnGrove Windows Forms Forums > how to remove duplicate items in dropdown list? Question 0 Sign In to Vote Reply | Quote | Sunday, March 29, 2009 4:15 AM Mantissa Corporation 35 Points I have a dropdown list column on a datagridview that is bound to a datasource with values like this 1 1 2 2 3 3 etc... And this is how they show up in my list. I only want the values 1-10 showing b ut I only want one of each number. I am sure i can handle it in the cellformatt ing event I am ju st not sure how Answers 0 Sign In to Vote Reply | Quote | Sunday, March 29, 2009 3:39 PM 35,075 Points Why don't you make a slight change in your SQL Statement to include the DISTINCT keyword? Can we see the code where you are performing the binding? I am assuming you are binding something from a Database table. John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com All Replies 0 Sign In to Vote Reply | Quote | Sunday, March 29, 2009 3:39 PM 35,075 Points Why don't you make a slight change in your SQL Statement to include the DISTINCT keyword? Can we see the code where you are performing the binding? I am assuming you are binding something from a Database table. John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com Windows Forms Data Controls and Databinding Vegeta4ss JohnGrove JohnGrove Dev Center Sign in

Transcript of How to Remove Duplicate Items in Dropdown List

7/21/2019 How to Remove Duplicate Items in Dropdown List

http://slidepdf.com/reader/full/how-to-remove-duplicate-items-in-dropdown-list 1/2

7/10/13 how to remove duplicate items in dropdown list?

social.msdn.microsoft.com/Forums/windows/en-US/61e81667-7b40-4f42-acc6-3731f680fc8b/how-to-remove-duplicate-items-in-dropdown-list 1/2

Answered by:

Top related threads

how to remove duplicate items indropdown list?

Remove duplicate items from list

How to merge items fromList<List<int>> to List<int> andremove duplicates in LINQ query

How do you remove a custom actionitem from the workflow Actiondropdown list in SharePointDesigner?

How to remove duplicate items forma listbox?

Ask a question

Quick Access

Search related threads Search forum questions

1353

JohnGrove's threads

iew Profile

35,075 Points

Lead Developer of an application designed

o help troubleshoot anything mechanical

hat is described with a schematic.

Particularly interested in Process

ptimization, .NET, Relational Database

Design, CGM, Vector Graphics, Object-

riented Techniques. I enjoy Judo, surfing,

hiking, weight-lifting, running, and of 

ourse programming.

JohnGrove

Windows Forms Forums >

how to remove duplicate items in dropdown list?

Question

0Sign In to

Vote

Reply | Quote |

Sunday, March 29, 2009 4:15 AM

Mantissa Corporation 35 Points

I have a dropdown list column on a datagridview that is bound to a datasource with values like this

1

1

2

2

3

3

etc...

And this is how they show up in my list. I only want the values 1-10 showing but I only want one of each

number. I am sure i can handle it in the cellformatting event I am just not sure how

Answers

0Sign In to

Vote

Reply | Quote |

Sunday, March 29, 2009 3:39 PM

35,075 Points

Why don't you make a slight change in your SQL Statement to include the DISTINCT keyword?

Can we see the code where you are performing the binding? I am assuming you are binding

something from a Database table.

John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com

All Replies

0Sign In to

Vote

Reply | Quote |

Sunday, March 29, 2009 3:39 PM

35,075 Points

Why don't you make a slight change in your SQL Statement to include the DISTINCT keyword?

Can we see the code where you are performing the binding? I am assuming you are binding

something from a Database table.

John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com

Windows Forms Data Controls and Databinding

Vegeta4ss

JohnGrove

JohnGrove

Dev Center

Sign in

7/21/2019 How to Remove Duplicate Items in Dropdown List

http://slidepdf.com/reader/full/how-to-remove-duplicate-items-in-dropdown-list 2/2

7/10/13 how to remove duplicate items in dropdown list?

social.msdn.microsoft.com/Forums/windows/en-US/61e81667-7b40-4f42-acc6-3731f680fc8b/how-to-remove-duplicate-items-in-dropdown-list 2/2

Centers

Dev Center Home

Windows Store apps

Internet Explorer

Desktop

Hardware

Other Windows sites

Enterprise

Small business

Students

Home users

Downloads

Windows 8

Visual Studio Express 2012 for Windows 8

Visual Studio Professional 2012

Internet Explorer 10 for Windows 7

Stay connected

Windows Store newsletter

Microsoft events

Windows Store for Developers Blog

Windows 8 App Developer Blog

© 2013 MicrosoftHello from Seattle. United States (English) Terms of Use Trademarks Privacy and Cookies

0Sign In to

Vote

Reply | Quote |

Monday, March 30, 2009 2:18 AM

Mantissa Corporation 35 Points

I suppose that would be an option.

I actually ran into a bigger issue with the dropdown list. Each time I selected a value instead of 

changing the current cell it jumped me to another cell in the same column. No clue what is happening

there.

So, because of that behavior I have switched back to textbox column for now. I will try your suggestion

and then hopefully i won't have that issue again with the selected value.

0Sign In to

Vote

Reply | Quote |

Friday, July 29, 2011 7:08 AM

15 Points

 void RemoveDuplicateItems(DropDownList ddl)

{

  for (int i = 0; i < ddl.Items.Count; i++)

{

ddl.SelectedIndex = i;

  string str = ddl.SelectedItem.ToString();

  for (int counter = i + 1; counter < ddl.Items.Count; counter++)

{ddl.SelectedIndex = counter;

  string compareStr = ddl.SelectedItem.ToString();

  if (str == compareStr)

{

ddl.Items.RemoveAt(counter);

counter = counter - 1;

}

}

}

}

Vegeta4ss

Ashish Tripathi