请教各位两个问题:1、怎样实现listview的排序? 2、怎样得到dataset里table的字段名,并逐条逐字段的读取值?

libraworm 2003-09-12 10:19:34
如题,我是用vc的,vc中用的callback函数,不知道在bcb里面如何实现?
dataset也是怎么也找不到字段名。。。。

多谢。
...全文
139 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhenyelchong 2003-09-14
  • 打赏
  • 举报
回复
这个帮主好像有问题吧?其中
Compare = CompareText(Item1->SubItems[ix], Item2->SubItems[ix]);
应该是
Compare = CompareText(Item1->SubItems->Item[ix], Item2->SubItems->Item[ix]);
好像是这样,我也有点忘了,但这只是Alpha排序,所以例如:22有可能排在5前面的
COKING 2003-09-13
  • 打赏
  • 举报
回复
////错了 int ix = ColumnToSort-1;
COKING 2003-09-13
  • 打赏
  • 举报
回复
int ColumnToSort = 0;

The OnColumnClick event handler sets the global variable to indicate the column to sort and calls AlphaSort:

void __fastcall TForm1::ListView1ColumnClick(TObject *Sender, TListColumn *Column)

{
ColumnToSort = Column->Index;
((TCustomListView *)Sender)->AlphaSort();
}


The OnCompare event handler causes the list view to sort on the selected column:

void __fastcall TForm1.ListView1Compare(TObject *Sender, TListItem *Item1, TListItem *Item2, int Data, int &Compare)
{
if (ColumnToSort == 0)
Compare = CompareText(Item1->Caption,Item2->Caption);
else
{
int ix = ColumnToSort ?1;
Compare = CompareText(Item1->SubItems[ix], Item2->SubItems[ix]);
}
}
//帮助里的例子
COKING 2003-09-13
  • 打赏
  • 举报
回复
2003-09-13 02:32:00 :zzzZZZ
libraworm 2003-09-13
  • 打赏
  • 举报
回复
再up一次
libraworm 2003-09-12
  • 打赏
  • 举报
回复
up

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧