Click here to Skip to main content
15,886,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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..
C#
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;
        }
        }
Posted

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

Let's see if "The Documentation" could possibly help: "How to: Implement Virtual Mode in the Windows Forms DataGridView Control"[^].
 
Share this answer
 
Comments
George Jonsson 15-Oct-15 3:46am    
You mean actually read the documentation??? :o
CPallini 15-Oct-15 3:56am    
Oh, no, no. No.
I referenced that just for completeness...
:-)
phil.o 15-Oct-15 3:56am    
Documentation can serve as a manual? I always thought it was only the original developpers' point of view about their solution.
CPallini 15-Oct-15 4:02am    
:-)
BillWoodruff 15-Oct-15 4:36am    
+5 Exactly what the OP deserves
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900