Datagrid和arraylist [英] Datagrid and arraylist

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

问题描述

我有一个数据源,其数据源是一个arraylist对象。 arraylist

包含特定课程的许多实例。


我有两个问题:

1 - 是有一种方法我可以获得对arraylist项目的引用

当前行指向?

2 - 是否可以对网格进行排序?


非常感谢提前。

解决方案

Stoljilcoviz,


你有什么当你使用数据表作为数据源时,ask就是非常简单。


对于其他系列,它可能也是好的,取决于你自己的

知识。


Cor


stojilcoviz,


假设数据网格正在显示arraylist中的arraylist项目

它们存在于arraylist中,你可以使用datagrid的CurrentRowIndex

作为arraylist'的Item属性的索引。这将允许您获得对arraylist中对象的

引用。


您可以通过对arraylist进行排序来对数据网格进行排序。


Kerry Moorman

" stojilcoviz"写道:

我有一个datagrid,其数据源是一个arraylist对象。 arraylist
拥有特定课程的许多实例。

我有两个问题:
1 - 有没有办法可以获得对arraylist item
当前行指向?
2 - 是否可以对网格进行排序?

非常感谢提前。



<柯********** @ discussions.microsoft.com>写在

新闻:5B ********************************** @ microsof t .com:


这将是一个解决方案。

我希望网格排序可以像数据表一样处理(即你

单击列标题,网格将根据您点击的列进行排序。


有人可以确认这对数据网格不起作用使用arraylist作为

数据源?

假设数据网格按照
顺序显示arraylist项目,它们存在于arraylist,你可以使用datagrid的
CurrentRowIndex作为arraylist'的Item属性的索引。这个
将让你获得对arraylist中对象的引用。

你可以通过对arraylist进行排序来对数据网格进行排序。

我'有一个数据源,它的数据源是一个arraylist对象。
arraylist拥有特定课程的许多实例。

我有两个问题:
1 - 有没有办法可以获得对arraylist
项目
当前行指向?
2 - 是否可以对网格进行排序?

非常感谢提前。




I''ve a datagrid whose datasource is an arraylist object. The arraylist
holds many instances of a specific class.

I''ve two questions about this:
1 - Is there a way by which I can obtain a reference to the arraylist item
the current row points to?
2 - Is it possible to sort the grid?

Many thanks in advance.

解决方案

Stoljilcoviz,

What you ask is all very simple when you use a datatable as datasource.

For other collections it is probably as well to do, what depends on your own
knowledge.

Cor


stojilcoviz,

Assuming that the datagrid is displaying the arraylist items in the order
that they exist in the arraylist, you can use the datagrid''s CurrentRowIndex
as an index to the arraylist''s Item property. This will let you obtain a
reference to the object in the arraylist.

You could sort the datagrid by sorting the arraylist.

Kerry Moorman
"stojilcoviz" wrote:

I''ve a datagrid whose datasource is an arraylist object. The arraylist
holds many instances of a specific class.

I''ve two questions about this:
1 - Is there a way by which I can obtain a reference to the arraylist item
the current row points to?
2 - Is it possible to sort the grid?

Many thanks in advance.



<Ke**********@discussions.microsoft.com> wrote in
news:5B**********************************@microsof t.com:

This would be a solution.
I hoped that grid sorting could be handled like for datatables (i.e. you
click the column header and the grid is sorted based on the column you
clicked).

Can somebody confirm that this doesn''t work on datagrid with arraylist as
datasource?

Assuming that the datagrid is displaying the arraylist items in the
order that they exist in the arraylist, you can use the datagrid''s
CurrentRowIndex as an index to the arraylist''s Item property. This
will let you obtain a reference to the object in the arraylist.

You could sort the datagrid by sorting the arraylist.

I''ve a datagrid whose datasource is an arraylist object. The
arraylist holds many instances of a specific class.

I''ve two questions about this:
1 - Is there a way by which I can obtain a reference to the arraylist
item
the current row points to?
2 - Is it possible to sort the grid?

Many thanks in advance.




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

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