473,387 Members | 3,781 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,387 software developers and data experts.

List Box Problem

List Box Multiple Selections
I have a list box on my page and I´m trying to add new
items on it. The insert operation must be under the
selected item. When I make the insertion it is done
perfect. But the problem begins when I make the insertion
under elements that are equal (same name I mean), the
element that I want to add is inserted after the first
repeted item, even if I select for example the last
position in the ListBox. Any Ideas?

Tengo un list box y estoy intentando adicionar elementos
dentro de el. La insercion se debe hace debajo del
elemento seleccionado. Cuando lo hago con multiples
selecciones el lo realiza perfectamente. El proble ma
comienza cuando hago la insercion de multiples elementos
que son iguales. La primera vez funciona perfecto, pero
cuando voy a adicionar un elemento debajo de uno de los
que esta repetidos, siempre se pone debajo del primer
elemento, asi seleccione la posicion del un elemento que
se encuentre mas abajo. Alguna Idea de como solucionarlo?
aqui esta el codigo:
Here is the code:

int pos = 0;
//List of the selected items by position
ArrayList listaPos = new ArrayList();
foreach (ListItem item in this.ListBoxLineas.Items)
{
if(item.Selected)
{
//Add the selected items by pos
listaPos.Add(pos);
}
pos++;
}

Array arrPos = listaPos.ToArray();
//Create the Linea to add
Clases.Linea lin = new SIG.Clases.Linea();
lin.IdLinea = this.txtIdLineas.Text.Trim();
lin.Descripcion=this.txtDecLineas.Text.Trim();
for(int cont=0;cont<arrPos.Length;cont++)
{
//position where I will add de line(Linea) in the
listBox
int where = (int)arrPos.GetValue(cont)+1+cont;
t.Insert(where,lin);
}
this.ListBoxLineas.DataSource=t;
this.ListBoxLineas.DataTextField="Descripcion";
this.DataBind();

Thanks

..
Nov 16 '05 #1
0 1493

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: KinŽsole | last post by:
Hi I'm very new to VB (using VB6) I have two lists one blank and one containing names in the format of surname and then forename.I also have a combo box containing forenames.When I select a...
35
by: Moosebumps | last post by:
Does anyone here find the list comprehension syntax awkward? I like it because it is an expression rather than a series of statements, but it is a little harder to maintain it seems. e.g. you...
1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
7
by: Shawn Windle | last post by:
----begin node.h-------- #ifndef NODE_H #define NODE_H #include <iostream> //NULL using namespace std; class node {
4
by: Piotr Sawuk | last post by:
First off, thanks for the help, this group was a great support for my efforts of learning c++. However, yet again I plan to throw away what I programmed and re-use a little more of what stl has to...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
7
by: Kieran Simkin | last post by:
Hi all, I'm having some trouble with a linked list function and was wondering if anyone could shed any light on it. Basically I have a singly-linked list which stores pid numbers of a process's...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
1
by: David Bilsby | last post by:
All Apologies for cross posing this but I am not sure if this is a VC 8 STL bug or simply an invalid use of the iterator. I have a PCI card access class which basically abstracts a third party...
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.