在GUI上显示二维数组值的最佳方法 [英] Best way to display a two dimensional array values on GUI

查看:86
本文介绍了在GUI上显示二维数组值的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我有几个相当大的二维数组,它们的数据类型不同,我需要向用户显示它们的值.我这样做的最佳选择是什么?我的第一次尝试是使用DataGrid,但是使用ItemsSource进行的绑定不适用于数组.显然,DataGrid将仅显示其绑定到的对象的属性值,并且数组中的值不会保留为属性.
将数组移到数据表中并将其绑定到数据网格是可行的,但是当我将数据量添加到数据表时,由于我的数据量很大,因此应用程序会滞后几秒钟.而且,这似乎是一种回旋处事方式.

您对此有何看法,您将如何解决这个问题?是否还有其他更适合此类任务的控件?除了显示值和滚动显示值外,我不需要任何其他功能.

Hi all!

I have a couple of rather large two-dimensional arrays with data of different datatypes, and I need to display their values to the user. What are my best options on doing this? My first attempt was using the DataGrid, however binding using ItemsSource did not work well with arrays. Apparently the DataGrid will only display the property values of the object it is bound to, and the values in an array are not kept as properties.
Moving the arrays into a datatable and binding it to the datagrid works, however with my amount of data the application lags for seconds when adding the data to the datatable. Also, it seems like a roundabout way of doing things.

What is your take on this, how would you solve such a problem? Are there any other controls which would be more suitable for such tasks? I do not require any functionality beyond displaying the values and scrolling through them.

推荐答案

不能创建具有两个属性的对象,然后创建包含两个属性的列表这些对象,并用数组填充列表?

Can''t you create a n object that has two properties, and then a list of those objects, and pump the list full with the array?

/////////////////////////////////////
public class MyItem
{
   public string Property1 { get; set; }
   public int Property2 { get; set; }
} 
<br />
/////////////////////////////////////
public class MyItemCollection : List<myitem>
{
    public MyItemCollection(Array myArray)
    {
        for (int i =0; i < myArray.Length; i++)
        {
            Add(new MyItem(){Property1 = myArray[i][0],
                             Property1 = myArray[i][1]});
        }
    }
}

...
MyItemCollection coll = new MyItemCollection(myArray);
...</myitem>



老实说,我不知道它的速度是否会比您已经完成的快,但这是可以尝试的...



I honestly don''t know if it''s going to be any faster than what you''ve already done, but it''s something to try...


有您吗?考虑过将Excel嵌入到您的应用程序中并让其显示您的数据?毕竟,Excel是为大型2D数据数组设计的.
Have you considered embedding Excel in your application and letting it present your data? Excel is, after all, designed for large 2d arrays of data.


ReportViewer具有此内置功能.向您的应用程序添加报告在此处添加网格!
ReportViewer has this build-in functionality. Add a report to your application add a grid there!


这篇关于在GUI上显示二维数组值的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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