There are 2 listboxes......listbox1 and listbox2
listbox1.datasource=datafile "datafile is file with items"
listebox1 has those items:
BBBBBB
------
CCCCC
------
AAAAAA
------
and listbox2 is empty.
now I want those data from listbox1 to be sorted i listbox2 but without string "----"
I have code for sorting them, but I dont know how to write code "sort them but don't take string "-----------" so sort them like that:
AAAAAA
BBBBBB
CCCCCC
always think that there is listbox1.datasource not listbox1.item
Thankyou !
Edit: Additional message of the OP moved here from solution
my solution is that, bur stil dooesnt work
string[] dataFromFile = lstQiftet.Items.Cast().ToArray();
Array.Sort(dataFromFile);
listBox1.DataSource = dataFromFile;
ArrayList arr = new ArrayList();
foreach (string s in dataFromFile)
if (s != "-----------------")
arr.Add(s);
arr.Sort();
listBox2.DataSource = arr;
why doesn't work
[Edit]Moved from non-solution of OP
THnx Thnx that work, but now after I delete "-----" , in first line is a space, I Try to delet that space like your code it isn't working.....
if (!s.StartsWith("-")&&!s.StartWith(" " ))..... is here any mistake or should be another code
[/Edit]
[Edit] Another non solution
thnx man friend I think I didnt explain as well you as I should
AAAA
----
BBBB
----
CCCC
----
afer i delet '-', then after sorted :
1
2. AAAA
3. BBBB
4. CCCC
the first line than is space.......so I dont want to be that space
[/Edit]