Hi, I'm doing a program in which I save all my elements in a combobox since no sé muy bien hacerlo con listas o diccionarios
.
The thing is that the combobox will be adding elements and increasing in size. The problem is that I need to select the last element every time a certain event occurs.
Well I add the elements in the following way and at the same time I quote that the combobox will increase in size as the program is working:
private void EntityLoad(DataInterceptedEventArgs obj){
var entities = HEntity.Parse(obj.Packet);
foreach(var entity in entities){
Index = entity.Index;
Id = entity.Id;
Profile = entity.FigureId;
playerList.Items.Add(entity.Index + "," + entity.Id + "," + entity.FigureId);
//MessageBox.Show("figure id: "+ entity.FigureId +"el id del buny" + entity.Id + "buny index:" + entity.Index+ ", position: "+ entity.Tile.X + "," + entity.Tile.Y + "," + entity.Tile.Z);
}
}
What I want to happen every time which for this is not necessary for you to help me as I know how to do it. What I want is that every time that event happens, the last element of my combobox. So my question is:
If I have un combobox que cambia de tamaño
I can sacar el ultimo elemento
each time my event is launched.
Second it is more advisable to use un diccionario o lista para guardar mis elementos
.
El combobox será dinamico
but I will tell you the moment only that I will need to know how to get the last element sabiendo que variará de tamaño
.
Here is a capture of the combobox that will increase as my program runs:
Correction: My goal is to take the last element of my combobox, save it and if possible make a split as a practical example that would help me a lot
Example.
Combobox:
"hola,dos,tres"
"1,dos,tres"
"2,dos,tres"
I'll get:
Obtener el ultimo elemento.
lo guardaré.
y haré un split para guardar los elementos por separado:
int i=2
string dos = "dos"
string tres = "tr"