473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

code for listbox1 to listbox2 move on button clik

how can retrive listbox1 to listbox2 without duplicate value
Jan 29 '10 #1
4 3136
tlhintoq
3,525 Expert 2GB
Your goal and question are completely unclear.
What is it that you need to accomplish?
Jan 29 '10 #2
I am use for this codes ,
listbox1 to listbox2 without duplicate add items ,But this codes add items with duplicate entry.
Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             int  j;
  4.             for (int i = listBox1.Items.Count - 1; i >= 0; --i  )
  5.             {
  6.                 j = listBox2.FindStringExact(listBox1.SelectedItem.ToString());
  7.                 if (j == -1)
  8.                 {
  9.                     listBox2.Items.Add(listBox1.Items[i ]);
  10.                 }
  11.                 else
  12.                 {
  13.                     MessageBox.Show("It fields are already added");
  14.                     return;
  15.                  }
Jan 31 '10 #3
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Jan 31 '10 #4
tlhintoq
3,525 Expert 2GB
So you want the item to appear to move from listbox1 to listbox2?
In line 9 you add the item to listbox2
Right after that remove it from listbox1
Expand|Select|Wrap|Line Numbers
  1. listBox1.Items.RemoveAt(i);
If the ListBox is new to you, I might suggest you read up on it so you can better understand it. A complete list of its methods along with sample code are available on the MSDN.
http://msdn.microsoft.com/en-us/libr...s.listbox.aspx
Jan 31 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: James Allen Bressem | last post by:
I was searching through the MSDN documentation trying to figure out how to do drag n drop and I found a sample program. The sample program did all sorts of fancy junk like dynamically create it's...
15
by: CR | last post by:
I've noticed that the trend these days is to declare variables in the middle of code instead of at the top. What is the advantage of this? It seems like it makes it hard to reuse variables. Here...
8
by: gumi | last post by:
Hi, I am looking for code for a alarm clock program that pops up a messege to be used as part of my VB.Net class project. Any help is very much appreciated. Thanks
0
by: marko svaco | last post by:
Hi, I have .Net VB and have worked with it, so I now some stuff in general. It woud be great if someone could help me, or give me some advice. I'm visiting a web page, so all the buttons and so...
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
1
by: Flemming Dahl | last post by:
Hi all, I want to create a button like this one.... open Microsoft Word select Edit select Replace clik on "More" button look at the "Special" button - now you've found it...
3
by: pooker75 | last post by:
Here is the code again and the error I get is Invalid Argument=Value of "-1" is not valid for 'index' Parameter Name:index Please advise the code so this error goes away and the program will...
0
by: silentbuddha | last post by:
Private Sub UserForm_Initialize() '----------- POPULATE LISTBOX 1 ----------- With ListBox1 .AddItem "--none--" .AddItem "Account...
17
by: radhikams | last post by:
Hi I want to create a drag drop tool box using javascript... Can anyone please guide me in this regard Thanks
3
by: rprasad79 | last post by:
Hi Team, Here goes the scenario... i have a listbox1 which contains continent details. if i select any one of the continent, then the next list box which contains the country list should display...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.