Sort C# ListBox Items -


i'm using c# adapter method, add elements list , after call list fill listbox, here button that:

private void button1_click(object sender, eventargs e) {   listcustomers.items.clear();   list < customer > customers = customerlist.getcustomers();   list < customersaldo > customerssaldo = customerlistsaldo.getcustomers();   int total = 0;   int totalcustomer = 0;   foreach(customer customer in customers)   total++;    listcustomers.items.clear();    totalcustomer = total;   int x = totalcustomer;    foreach(customersaldo customer2 in customerssaldo) {     if (x >= 1) {       listcustomers.items.add("costumer id # " + x + " is: " + customer2.saldo);       x--;      }   }  } 

result

this get, it's ok want know if exists way example:

costumer #1 saldo...
costumer #2 saldo...
costumer #3 saldo...

if see code have variable x, variable total number of costumers, think sort has start variable, don't know how it, can do?

reverse list , start counting untill reach end:

//reverse list customerssaldo.reverse(); //add new items for(int = 0; < customers.count; i++)      listcustomers.items.add(string.format("costumer id # {0} is: {1}", (i+1).tostring(), customerssaldo[i].saldo); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -