如何在Winforms应用程序中添加40k行? [英] How to add 40k rows in Winforms application?

查看:64
本文介绍了如何在Winforms应用程序中添加40k行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows表单应用程序,它将数据绑定到gridview。我只想显示不编辑的数据。我每行有32列。当我有40k行显示gridview时,只显示大约25k行,其余的行不会显示,甚至在我导出时也不在excel中。我开始知道WPF是更好的选择,但我已经完成了我的工作,没有时间在WPF中重新创建整个应用程序。听说虚拟模式使它工作,但我不知道如何在我的胜利形式中实现它..下面是我的显示形式代码..请帮我改变代码显示40k行..明天是我的截止日期..提前谢谢..

Hi, I have a windows form app which binds data to a gridview. I just want to display data not editing. I have 32 columns in each row. When I have 40k rows to display gridview shows only around 25k rows,rest of the rows are not displayed and not even in excel when i exported. I came to know that WPF is better option but i have already finished my work,no time to recreate entire app in WPF. Heard that virtual mode makes it work but i dono how to implement it in my win form.. Below is my display form code.. Pls help me with the code changes to display 40k rows..tomorrow is my deadline..thanks in advance..

namespace HSR_GvHo_Report
{
    public partial class DataDisplay : Form
    {
        public static string _TableNm,_TableNm3, _FromDate, _TillDate,_frmdate,_todate, connstrr;
        //SqlConnection conn;
        MenuParams mparams = new MenuParams();
        string path;
        DataTable dt;
 public DataDisplay(string _TableName, string _TableName3,string _FDate, string _TDate, string _FrDate, string _ToDate, string constr)
        {
           
            InitializeComponent();
            _TableNm = _TableName;
            _TableNm3 = _TableName3;
            _FromDate = _FDate;
            _TillDate = _TDate;
           _frmdate=_FrDate;
            _todate=_ToDate;
            connstrr = constr;

        }private void DataDisplay_Load(object sender, System.EventArgs e)
        {
            lblFrom.Text = _FromDate;
            lblTill.Text = _TillDate;

            //Data to Load Grid
            dt = CreateDataTable(_TableNm);
            dgLoadData.DataSource = dt;
             private DataTable CreateDataTable(string _TableNm)
        {
            string Qry = null;
            dt = new DataTable();
            using (SqlConnection conn = new SqlConnection(connstrr))
            {
                try
                {
                    if (conn.State == ConnectionState.Closed || conn.State == ConnectionState.Broken)
                    {
                        conn.Open();
                    }
                    string b  = _FromDate;
                    string b1 = _TillDate;

             Qry = "select  GLZone,GLState,GLCity,a.Showroomname,a.Stockno,b.Field1,Class1Cd,Class2Cd,SubClass1Cd,SubClass2Cd,Sizecd,ItemDesc,"+
" a.MonthOpDate,a.OpeningQty,PurchaseQty,SReturnQty,a.ReceiptDate,PurRetQty,SalesQty,a.ClosingQty,DaysOld,Retail_Price,"+
" Cost_Price,CashSaleVal,CashRetVal,AnalCode1,AnalCode2,AnalCode3,AnalCode4,AnalCode5,userid"+
 
"From  TEMPSTOCKMOVEMENTsuper as a left join TEMPConIMEIsuper as b "+

"on a.Showroomname=b.Showroomcode and a.Stockno=b.Stockno and a.MonthOpDate=b.MonthOpDate"+
" ORDER BY GLZone,GLState,GLCity,Showroomname,Stockno,Class1Cd,Class2Cd,SubClass1Cd,SubClass2Cd,Sizecd,ItemDesc ";
             //and ReceiptDate between  '" + b + "' and '" + b1 + "'
                    SqlDataAdapter da = new SqlDataAdapter(Qry, conn);
                    da.Fill(dt);
                }
                catch (Exception ex)
                {
                    LogWriter.WriteLine(ex.Message);
                    LogWriter.WriteLine(ex.StackTrace);
                }
                finally
                {
                    if (conn.State == ConnectionState.Open || conn.State == ConnectionState.Connecting)
                    {
                        conn.Close();
                    }
                }
            }

            return dt;
        }
        }

推荐答案

引用:

听说虚拟模式使其工作但我不知道如何以我的胜利形式实现它。

Heard that virtual mode makes it work but i dono how to implement it in my win form.



让我们看看文档是否可能有所帮助:如何:在Windows窗体DataGridView控件中实现虚拟模式 [ ^ ] 。


不要。



从你的用户的角度停下来想一想:它要花多长时间让他从40,000的显示中找到他感兴趣的行?

假设20到一个页面(大约是平均值)并且他以我的正常阅读速度读取,那就是超过半小时只是为了翻页通过每一个页面的数据/>


你真的认为这是一个好的设计吗?你想每天都这样做吗?因为如果我被期望,该应用程序会因极端偏见而被卸载,我会要求退还我的钱!



相反,最多显示4或5页,提供搜索和过滤器 - 使用户可以轻松找到他需要的数据。
Don't.

Stop and think about it from your user's point of view: how long is it going to take him to find the row he is interested in from a display of 40,000?
Assuming 20 to a "page" (which is about average) and that he reads at my normal reading speed, that's going to be over half an hour just to "page down" through each and every "page" of data.

Do you really think that is a good design? Would you like to do that every day? Because if I was expected to, that app would get uninstalled with extreme prejudice and I'd be demanding my money back!

Instead, show at most 4 or 5 pages, provide searches and filters - make it easy for the user to find the data he needs.


这篇关于如何在Winforms应用程序中添加40k行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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