473,800 Members | 2,529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

code for listbox1 to listbox2 move on button clik

2 New Member
how can retrive listbox1 to listbox2 without duplicate value
Jan 29 '10 #1
4 3155
tlhintoq
3,525 Recognized Expert Specialist
Your goal and question are completely unclear.
What is it that you need to accomplish?
Jan 29 '10 #2
rajesh kunwar
2 New Member
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 Recognized Expert Specialist
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 Recognized Expert Specialist
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
4963
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 user controls etc. (pomp - is it really necessary to be so gaudy when trying to explain a simple point?) So, realizing the state of the economy and the period of history in which I was so unfortunately born, I spent the next 3 or so hours weeding...
15
2973
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 is how all the examples I've seen so far create an OleDbCommand Object: Dim cmd as new OleDbCommand("Select * FROM Table1",cnn) I had to figure out that it was the same as this:
8
2501
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
1363
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 on are always on the same coordinants. So I would just have to make a program which when I run, would open Internet Explorer, go to that web page and then first log on, and then clik everything i need. The problem is that the links are very long,...
1
5742
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 database - containing a list of addresses. Sequence of events is = (1) Excel template opens in its default XXX.xls filename. (2) Code runs to save the spreadsheet as XXX.xls. (3) User clicks a button to open an Access database containing an
1
1165
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
1173
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 still execute correctly. Other suggestions posted either still give errors or the program does not execute once I put the suggestion in. Thanks for your help. Jo Ann Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As...
0
1088
by: silentbuddha | last post by:
Private Sub UserForm_Initialize() '----------- POPULATE LISTBOX 1 ----------- With ListBox1 .AddItem "--none--" .AddItem "Account Maintenance" .AddItem "Change Service Status" .AddItem "Credit and Collections"
17
4719
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
1370
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 the countries corresponding to the continent. similarly when i select the corresponding country, i should get the list of cities which are there in the continent+country list in the 3rd llistbox. Can you please give me an example for the same....
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10504
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10274
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.