Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2007

Tip: Looking for answers? Try searching our database.

TabStrip\TableFlowLayoutPanel\Control resizing issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
s_armondi - 09 Jul 2007 12:01 GMT
Hi Group,
               I'm having a problem with control resizing.
My application uses a TabStrip control (where pages are added and
removed in code, on the fly). Within the page, there are two splitters
(nested) and within one of the splitters a TableLayoutPanel, which
hosts 3 custom controls. The problems occurs when I resize the form.
The tab page which has the focus resizes as expected, but the non-
visible (non-focused) pages do not. I think I've set all of the
relevant Dock properties to the correct values - does anyone have any
suggestions?

I've pasted my code below (snipped for clarity), any suggestions are
welcome!
Thanks,
s_armondi

Screen Layout Diagram (apologies if the formatting screws it up!):
|-------------------|------------|
|                   |            |  <- Ticker 1
|    dgPrices  |------------|
|-------------------|            |  <- Ticker 2
|                   |------------|
|     dgTicker  |            |  <- Ticker 3
|-------------------|------------|

private void LayoutGrids()
       {
           TabPage pg;
           BindingSource src;
           DataGridView dgPrices, dgTicker;
           SplitContainer primarySplitter, secondarySplitter;
           //Columns
           DataGridViewImageColumn showDepthCol;
           DataGridViewTextBoxColumn periodCol, bidSourceCol,
bidQuantityCol, bidCol, offerCol, offerQuantityCol,
                                       offerSourceCol, lastCol,
lastQuantityCol, lastSourceCol;

           dgPrices = new DataGridView();
           bindingSources.Clear();

           if (clientObject.SubscribedCommodities.Length > 0)
           {
               foreach (string Commodity in
clientObject.SubscribedCommodities)
               {
                   <SNIP>
                   //create the DataGridView for the prices.
                   dgPrices = new DataGridView();
                   //Tag is used in other code to identify the
commodity of the prices being displayed.
                   dgPrices.Tag = Commodity;
                   dgPrices.Anchor = AnchorStyles.Top |
AnchorStyles.Left;
                   dgPrices.AutoGenerateColumns = false;
                   dgPrices.RowHeadersVisible = false;
                   dgPrices.SelectionMode =
DataGridViewSelectionMode.FullRowSelect;
                   dgPrices.AllowUserToAddRows = false;
                   dgPrices.AllowUserToDeleteRows = false;
                   dgPrices.AllowUserToOrderColumns = true;
                   dgPrices.AllowUserToResizeColumns = false;
                   dgPrices.AllowUserToResizeRows = false;
                   dgPrices.ClipboardCopyMode =
DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;

                   //event handlers
                   dgPrices.CellFormatting += new
DataGridViewCellFormattingEventHandler(dg_CellFormatting);
                   dgPrices.CellMouseClick += new
DataGridViewCellMouseEventHandler(dg_CellMouseClick);
                   dgPrices.MouseDown += new
MouseEventHandler(dgPrices_MouseDown);
                   //add the context (right-click) menu
                   dgPrices.ContextMenuStrip = priceContextMenu;

                   //store the DataGridView
                   priceGrids.Add(Commodity, dgPrices);

                   #region Column creation
                   <SNIP>
                   #endregion

                   dgPrices.DataSource = bindingSources[Commodity];
                   dgPrices.Dock = DockStyle.Fill;
                   bindingSources[Commodity].DataSource =
clientObject.GetData(Commodity);

                   //create the DataGridView for the trade ticker.
                   dgTicker = new DataGridView();
                   dgTicker.Tag = Commodity;
                   //dgTicker.AutoGenerateColumns = true;
                   dgTicker.DataSource =
tickerBindingSources[Commodity];
                   dgTicker.SelectionMode =
DataGridViewSelectionMode.CellSelect;
                   dgTicker.RowHeadersVisible = false;
                   tickerBindingSources[Commodity].DataSource =
clientObject.GetTickerData(Commodity);
                   dgTicker.Dock = DockStyle.Fill;

                   #region Ticker Column Creation
                   <SNIP>
                   #endregion

                   tickerGrids.Add(Commodity, dgTicker);

                   primarySplitter = new SplitContainer();
                   primarySplitter.Anchor = AnchorStyles.Top |
AnchorStyles.Left;
                   primarySplitter.Dock = DockStyle.Fill;
                   primarySplitter.Orientation =
Orientation.Vertical;
                   //split the screen 65/35
                   primarySplitter.SplitterDistance = (int)
(primarySplitter.Width * 0.65);
                   primarySplitter.SplitterMoved += new
SplitterEventHandler(primarySplitter_SplitterMoved);

                   secondarySplitter = new SplitContainer();
                   secondarySplitter.Orientation =
Orientation.Horizontal;
                   secondarySplitter.Dock = DockStyle.Fill;
                   secondarySplitter.Panel1.Controls.Add(dgPrices);
                   secondarySplitter.Panel2.Controls.Add(dgTicker);
                   secondarySplitter.SplitterMoved += new
SplitterEventHandler(secondarySplitter_SplitterMoved);


primarySplitter.Panel1.Controls.Add(secondarySplitter);

                   TableLayoutPanel tbl = new TableLayoutPanel();
                   tbl.RowCount = 3;
                   tbl.ColumnCount = 1;
                   tbl.RowStyles.Add(new RowStyle(SizeType.Percent,
100 / 3));
                   tbl.RowStyles.Add(new RowStyle(SizeType.Percent,
100 / 3));
                   tbl.RowStyles.Add(new RowStyle(SizeType.Percent,
100 / 3));
                   tbl.ColumnStyles.Add(new
ColumnStyle(SizeType.Percent, 100));
                   tbl.Dock = DockStyle.Fill;

                   tickerGraphs.Add(Commodity, new
TickerGraphControl[3]);
                   TickerGraph[] tickers =
clientObject.TickerGraphManager.GetTickerGraphs(Commodity);
                   TickerGraph t1 = null, t2 = null, t3 = null;
                   if (tickers != null)
                   {
                       if (tickers.Length > 0)
                           t1 = tickers[0];
                       if (tickers.Length > 1)
                           t2 = tickers[1];
                       if (tickers.Length > 2)
                           t3 = tickers[2];
                   }

                   TickerGraphControl cht = new TickerGraphControl();
                   cht.Dock = DockStyle.Fill;
                   cht.Name = "Ticker1";
                   cht.BackColor = this.BackColor;
                   cht.ContextMenuStrip = tickerContextMenu;
                   tbl.Controls.Add(cht, 0, 0);
                   cht.Ticker = t1;
                   tickerGraphs[Commodity][0] = cht;

                   cht = new TickerGraphControl();
                   cht.Dock = DockStyle.Fill;
                   cht.Name = "Ticker2";
                   cht.BackColor = this.BackColor;
                   cht.ContextMenuStrip = tickerContextMenu;
                   tbl.Controls.Add(cht, 0, 1);
                   cht.Ticker = t2;
                   tickerGraphs[Commodity][1] = cht;

                   cht = new TickerGraphControl();
                   cht.Dock = DockStyle.Fill;
                   cht.Name = "Ticker3";
                   cht.BackColor = this.BackColor;
                   cht.ContextMenuStrip = tickerContextMenu;
                   tbl.Controls.Add(cht, 0, 2);
                   cht.Ticker = t3;
                   tickerGraphs[Commodity][2] = cht;

                   primarySplitter.Panel2.Controls.Add(tbl);

                   pg = new TabPage(Commodity);
                   pg.Controls.Add(primarySplitter);
                   tabPrices.TabPages.Add(pg);

                   primarySplitters.Add(Commodity, primarySplitter);
                   secondarySplitters.Add(Commodity,
secondarySplitter);
               }
           }
           else
           {
               <SNIP>
           }
Jeff Gaines - 09 Jul 2007 12:33 GMT
On 09/07/2007 in message

>Hi Group,
>                 I'm having a problem with control resizing.
[quoted text clipped - 6 lines]
>relevant Dock properties to the correct values - does anyone have any
>suggestions?

This is a problem with the Tab Control, not with what you are doing.

For tab pages that are not visible the control sets their position using
large negative numbers which places them off screen. If you do your
resizing in the Tab Control Index Changed event, just for the newly
selected tab page, I think you will find it works.

Signature

Jeff Gaines


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.