Multiple Page Strips Leading to single page

6 posts, 0 answers
  1. Eugene Bykov
    Eugene Bykov avatar
    9 posts
    Member since:
    Sep 2009

    Posted 29 Oct 2010 Link to this post

    Hello!

    I wonder is it possible to implement the following example?
    I wish to have two pages of a PageView, but wish them to lead to a single GridView.

    The reason for that is that the application uses to much memory and starts working slowly if I have multiple "heavy controls". I tried to create a form with four grids on different pages of a PageView, but I experience delays when switching tabs and even starting the application.

    Here I try to implement the situation when two grids have very much alike data (say "New Events" and "Old events"), populated from one very same table on SQL server. The only difference between two sets of data is a "bit" field indicating whether this is an old event or a new one. I guess it's too much to create a special grid for each data set. And, as long as we are planning to move from Delphi, there is a TTabControl - which does what I wish. Well, almost exactly - with Delphi control I cannot create three tabs, two of which lead to one page and the third - to another.

    I hope I can implement this with RadPageView.
    Thank you.
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 29 Oct 2010 Link to this post

    Hello Eugene,

    You can, but in order to do it well and clean, you should switch the pageview to a different look.

    I have prepared a very basic example on how you could achieve this behavior using the Outlook View of the RadPageView:
    using System;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
     
    public partial class Form1 : Form
    {
        private RadGridView radGridView1;
        private RadPageView radPageView1;
     
        public Form1()
        {
            InitializeComponent();
            InitializeGrid();
     
            this.Controls.Add(radPageView1 = new RadPageView());
            radPageView1.ViewMode = PageViewMode.Outlook;
            radPageView1.Width = 100;
            radPageView1.Dock = DockStyle.Left;
            radPageView1.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
            radPageView1.Pages.Add(new RadPageViewPage
            {
                Text = "Page1"
            });
     
            radPageView1.Pages.Add(new RadPageViewPage
            {
                Text = "Page2"
            });
        }
     
        void radPageView1_SelectedPageChanged(object sender, EventArgs e)
        {
            var pageView = sender as RadPageView;
            if (radGridView1.Columns.Count == 0)
            {
                return;
            }
     
            if (pageView.SelectedPage.Text == "Page1")
            {
                radGridView1.Columns[1].IsVisible = true;
            }
            else
            {
                radGridView1.Columns[1].IsVisible = false;
            }
        }
     
        private void InitializeGrid()
        {
            this.Controls.Add(radGridView1 = new RadGridView());
            radGridView1.Dock = DockStyle.Fill;
            radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
     
            var list = new List<Test>();
            for (int i = 0; i < 10; i++)
            {
                list.Add(new Test
                {
                    Id = i,
                    Name = "name" + i
                });
            }
     
            radGridView1.DataSource = list;
        }
     
        public class Test
        {
            public int Id
            {
                get;
                set;
            }
     
            public string Name
            {
                get;
                set;
            }
        }
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Eugene Bykov
    Eugene Bykov avatar
    9 posts
    Member since:
    Sep 2009

    Posted 29 Oct 2010 Link to this post

    Thanks, Emanuel for a reply!
    I tried to play a little with
    this.Controls.Add()

    and realised - why cannot I do this - thought I can:
    private void radPageView1_SelectedPageChanged(object sender, EventArgs e)
    {
        radPageView1.SelectedPage.Controls.Add(radGridView1);
    }

    And indeed it works just fine, the grid moves between pages, the only thing I need to do is check, which page is selected and do I need to update grid information and move the grid itself to currently selected page.

    The only thing I notice is a very small flashing. Well that's ok, as long as I switch to the tab which has no grid at first.

    Thank you!
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 29 Oct 2010 Link to this post

    Hello Eugene,

    I would advise against doing this, because every time you remove the grid from a control collection it unbinds, and then rebinds when you add it to a new control collection.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  6. Eugene Bykov
    Eugene Bykov avatar
    9 posts
    Member since:
    Sep 2009

    Posted 29 Oct 2010 Link to this post

    Ok, then a question is: if anyway I need to make a call to the server when switching tabs (to refresh data which could have been changed) - will it give any trouble? The code I posted was simplified as much as I could - I do intend to make a call to SQL server each time I switch tabs, so in this case would you still advise me not to implement my approach with unbinding and binding again?
  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 30 Oct 2010 Link to this post

    Hello Eugene,

    If you want to make a call to the db every time the selected page changed, in my point of view the best approach would be to use a different grid on each page, this way just for the data binding process will be time and memory consuming, but if you are removing and adding controls, you will waste more time and resources with the internals of the grid also, loading of the layout processing the internals, themes, and so on.

    You could also just use a timer to refresh data every minute or so, not on each selected page changed event, it should help improve the performance of the application.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
Back to Top
UI for WinForms is Visual Studio 2017 Ready