Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear friends dan vb master,

Please help me. I'm newbie at vb. I use visual basic 2010. I have a DataGridSJF with several row. I want to sort it with ascending mode except the first row.

the data is at the 3rd column:
12
3
5
2
1

I want the result like this:
12
1
2
3
5

Here is my code:

SQL
For j = 1 To DataGridSJF.Rows.Count - 2
           DataGridSJF.Rows(0).Cells("BurstTime").Selected = False
           DataGridSJF.Sort(DataGridSJF.Columns(3), System.ComponentModel.ListSortDirection.Ascending)
       Next


It doesn't work. Can anybody help me?

Sorry for my bad English. Thanks.
Posted
Updated 21-Apr-13 2:36am
v2

1 solution

First of all... it doesn't work does not help much to understand your problem. Please use the widget "improve question" and give a bit more information about what is not working.

On the other hand, why are you using "Row.Count - 2" ??

If you want to skip the first row, with j = 1 (if Zero-Based) or j = 2 (with 1-Based) should be enough. Your index should go until the end, that means the full "Rows.Count". Unless you have other things at the bottom you don't want to consider (you only tell about first row).

another thing I don't really understand...

If you are programming a For-Loop, why are you not using the indexator at all?
You have "j" changing at each repetition but you have hard-coded Row(0) and Columns(3). Why the loop then?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900