没有第一行排序Datagrid [英] Sorting Datagrid without first Row

查看:129
本文介绍了没有第一行排序Datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友dan vb大师,



请帮助我。我是vb的新手。我使用visual basic 2010.我有一个DataGridSJF,有几行。我想用升序模式对它进行排序,除了第一行。



数据在第3栏:

12

3

5

2

1



我想得到这样的结果:

12

1

2

3

5



这是我的代码:



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:

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.

推荐答案

首先......它没有用,对理解你的问题没什么帮助。请使用小部件改进问题并提供更多有关不起作用的信息。



另一方面,为什么使用Row.Count - 2??



如果你想跳过第一行,j = 1(如果是基于零)或j = 2(基于1)应该足够。您的索引应该一直持续到最后,这意味着完整的Rows.Count。除非你有其他的东西在底部你不想考虑(你只讲第一排)。



另一件我不太懂的东西...



如果您正在编写For-Loop,为什么不使用索引器?

你有j 每次重复都会改变,但你有硬编码的Row(0)和Columns(3)。为什么循环呢?
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?


这篇关于没有第一行排序Datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆