Windows Develop Bookmark and Share   
 index > Windows Forms Designer > scroll bar is hidden in my user control
 

scroll bar is hidden in my user control

hi guys, well, im here with another issue and my new problem is that i have a blank user control called ucNewsList, wich is filled with a list of user controls called ucNewsListItem, well my problem is that even if i set my autoscroll property on my ucNewsList control, the scroll bar its still hidden, i know its there because when the form loads it appears, but it dissapears when the control is filled, i already tried adding a panel to my user control and filling the panel instead of the control, but with no success, this is my code, im not sure if im missing a property, any suggestions will be appreciated

 if(newsList.Count!=0){
                    bool changeColor = false;
                    foreach (News noticia in newsList)
                    {
                        changeColor = changeColor == true ? false : true;

                        panItemPanel = new Panel();
                        nwsiNewItem = new ucNewsListItem(noticia, changeColor);
  
                        // fills NewsListItem to a new panel
                        panItemPanel.Controls.Add(nwsiNewItem);
                        nwsiNewItem.Dock = DockStyle.Fill;
                        nwsiNewItem.Visible = true;

                        // adds newsListitem to the control
                        
                        this.Controls.Add(panItemPanel);
                        panItemPanel.Dock = DockStyle.Top;
                        panItemPanel.Visible = true;
                        panItemPanel.Height = 50;
                    }
                    this.bFirstTime = false;
                }
  • Moved byRoahn LuoMSFTFriday, July 10, 2009 10:19 AMa Windows Forms control issue. (From:Visual C# General)
  •  
juanitoHCPunk  Thursday, July 09, 2009 12:13 AM

Well, it could be really difficult to think of a reason for this without actually looking at the controls design.

But I suspect one possibility:
As per my understanding, you need scroll on the main control-parent control, right?
I think, you need to leave a space for the scrollbar in the main control and then on the remaining part, have a full stretched Panel but not in the scroll area.
Now, add controls to this Panel and Dock it to Fill as you are doing.

Hope, I have understood you well and have explained you well.


Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Thursday, July 09, 2009 12:39 AM

Well, it could be really difficult to think of a reason for this without actually looking at the controls design.

But I suspect one possibility:
As per my understanding, you need scroll on the main control-parent control, right?
I think, you need to leave a space for the scrollbar in the main control and then on the remaining part, have a full stretched Panel but not in the scroll area.
Now, add controls to this Panel and Dock it to Fill as you are doing.

Hope, I have understood you well and have explained you well.


Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
nope, i already tried that, something very odd is that when i set dockstyle to left, the horizontal scroll bar appeared and stayed there, but when i set it to top or botom, it appears, then it dissapears when the control fills
juanitoHCPunk  Thursday, July 09, 2009 1:21 AM
Sorry. Cannot think of more possibilities without actually looking at the controls.
All the best! Carry on. Please post your solution when you achieve it. Would be interesting to know the reason.
Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Thursday, July 09, 2009 1:36 AM
im still looking for an anwer =( this is my onpaint event for the newslist control

protected override void OnPaint(PaintEventArgs e)
        {
            if (this.bFirstTime)
            {
                newsList = nwsNew.getRssNews();
                if(newsList.Count!=0){
                    bool changeColor = false;
                    foreach (News noticia in newsList)
                    {
                        changeColor = changeColor == true ? false : true;

                        panItemPanel = new Panel();
                        nwsiNewItem = new ucNewsListItem(noticia, changeColor);
                        nwsiNewItem.NewsClick += new ucNewsListItem.NewsClickEvent(nwsiNewItem_Click);
  
                        // Se agrega el NewsListItem al nuevo panel
                        panItemPanel.Controls.Add(nwsiNewItem);
                        nwsiNewItem.Dock = DockStyle.Fill;
                        nwsiNewItem.Visible = true;

                        // Se agrega el nuevo Panel al control

                        this.Controls.Add(panItemPanel);
                        panItemPanel.Dock = DockStyle.Bottom;
                        panItemPanel.Visible = true;
                        panItemPanel.Height = 50;
                    }
                    this.AutoScroll = true;
                    this.bFirstTime = false;
                }
            }
            base.OnPaint(e);
        }
this is the designer, as you can see it has its default properties, the only thing that changes is the autoscroll to true

private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // ucNewsList
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.AutoScroll = true;
            this.AutoValidate = System.Windows.Forms.AutoValidate.Disable;
            this.BackColor = System.Drawing.Color.White;
            this.Name = "ucNewsList";
            this.ResumeLayout(false);

        }
this is my contructor for my newsItem

public ucNewsListItem(News nwsParam,bool bChangeColor)
        {
            noticia = nwsParam;
            InitializeComponent();
            this.lblHeader.Text = nwsParam.Title;
            this.lblContent.Text = nwsParam.Content;
            this.pnlNext.Width = 0;

            if (bChangeColor)
            {
                this.pnlBottomBorder.BackColor = Color.White;
                this.pnlItemContainer.BackColor = Color.White;
                this.pnlNext.BackColor = Color.White;
                this.pnlTopBorder.BackColor = Color.White;
            }
            else
            {
                this.pnlBottomBorder.BackColor = Color.FromArgb(228, 228, 228);
                this.pnlItemContainer.BackColor = Color.FromArgb(228, 228, 228); 
                this.pnlNext.BackColor = Color.FromArgb(228, 228, 228);
                this.pnlTopBorder.BackColor = Color.FromArgb(228, 228, 228);
            }
        }
and its designer

 private void InitializeComponent()
        {
            this.lblHeader = new System.Windows.Forms.Label();
            this.lblContent = new System.Windows.Forms.Label();
            this.picbThumb = new System.Windows.Forms.PictureBox();
            this.pnlTopBorder = new System.Windows.Forms.Panel();
            this.pnlItemContainer = new System.Windows.Forms.Panel();
            this.pnlNext = new System.Windows.Forms.Panel();
            this.lblArrow = new System.Windows.Forms.Label();
            this.pnlBottomBorder = new System.Windows.Forms.Panel();
            this.pnlItemContainer.SuspendLayout();
            this.pnlNext.SuspendLayout();
            this.SuspendLayout();
            // 
            // lblHeader
            // 
            this.lblHeader.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Bold);
            this.lblHeader.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(42)))), ((int)(((byte)(42)))), ((int)(((byte)(42)))));
            this.lblHeader.Location = new System.Drawing.Point(40, 7);
            this.lblHeader.Name = "lblHeader";
            this.lblHeader.Size = new System.Drawing.Size(100, 12);
            this.lblHeader.Text = "Header";
            // 
            // lblContent
            // 
            this.lblContent.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular);
            this.lblContent.ForeColor = System.Drawing.Color.DimGray;
            this.lblContent.Location = new System.Drawing.Point(40, 20);
            this.lblContent.Name = "lblContent";
            this.lblContent.Size = new System.Drawing.Size(160, 30);
            this.lblContent.Text = "Content";
            // 
            // picbThumb
            // 
            this.picbThumb.BackColor = System.Drawing.Color.Gray;
            this.picbThumb.Location = new System.Drawing.Point(5, 8);
            this.picbThumb.Name = "picbThumb";
            this.picbThumb.Size = new System.Drawing.Size(28, 20);
            // 
            // pnlTopBorder
            // 
            this.pnlTopBorder.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(228)))), ((int)(((byte)(228)))), ((int)(((byte)(228)))));
            this.pnlTopBorder.Dock = System.Windows.Forms.DockStyle.Top;
            this.pnlTopBorder.Location = new System.Drawing.Point(0, 0);
            this.pnlTopBorder.Name = "pnlTopBorder";
            this.pnlTopBorder.Size = new System.Drawing.Size(280, 1);
            // 
            // pnlItemContainer
            // 
            this.pnlItemContainer.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(228)))), ((int)(((byte)(228)))), ((int)(((byte)(228)))));
            this.pnlItemContainer.Controls.Add(this.pnlNext);
            this.pnlItemContainer.Controls.Add(this.picbThumb);
            this.pnlItemContainer.Controls.Add(this.lblHeader);
            this.pnlItemContainer.Controls.Add(this.lblContent);
            this.pnlItemContainer.Dock = System.Windows.Forms.DockStyle.Fill;
            this.pnlItemContainer.Location = new System.Drawing.Point(0, 1);
            this.pnlItemContainer.Name = "pnlItemContainer";
            this.pnlItemContainer.Size = new System.Drawing.Size(280, 57);
            this.pnlItemContainer.Click += new System.EventHandler(this.pnlItemContainer_Click);
            this.pnlItemContainer.GotFocus += new System.EventHandler(this.pnlItemContainer_GotFocus);
            this.pnlItemContainer.LostFocus += new System.EventHandler(this.pnlItemContainer_LostFocus);
            // 
            // pnlNext
            // 
            this.pnlNext.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(228)))), ((int)(((byte)(228)))), ((int)(((byte)(228)))));
            this.pnlNext.Controls.Add(this.lblArrow);
            this.pnlNext.Dock = System.Windows.Forms.DockStyle.Right;
            this.pnlNext.Location = new System.Drawing.Point(254, 0);
            this.pnlNext.Name = "pnlNext";
            this.pnlNext.Size = new System.Drawing.Size(26, 57);
            this.pnlNext.Click += new System.EventHandler(this.pnlNext_Click);
            // 
            // lblArrow
            // 
            this.lblArrow.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Regular);
            this.lblArrow.ForeColor = System.Drawing.Color.White;
            this.lblArrow.Location = new System.Drawing.Point(4, 20);
            this.lblArrow.Name = "lblArrow";
            this.lblArrow.Size = new System.Drawing.Size(19, 20);
            this.lblArrow.Text = "â–?quot;;
            // 
            // pnlBottomBorder
            // 
            this.pnlBottomBorder.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(228)))), ((int)(((byte)(228)))), ((int)(((byte)(228)))));
            this.pnlBottomBorder.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.pnlBottomBorder.Location = new System.Drawing.Point(0, 58);
            this.pnlBottomBorder.Name = "pnlBottomBorder";
            this.pnlBottomBorder.Size = new System.Drawing.Size(280, 1);
            // 
            // ucNewsListItem
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(228)))), ((int)(((byte)(228)))), ((int)(((byte)(228)))));
            this.Controls.Add(this.pnlItemContainer);
            this.Controls.Add(this.pnlBottomBorder);
            this.Controls.Add(this.pnlTopBorder);
            this.Name = "ucNewsListItem";
            this.Size = new System.Drawing.Size(280, 59);
            this.pnlItemContainer.ResumeLayout(false);
            this.pnlNext.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Label lblHeader;
        private System.Windows.Forms.Label lblContent;
        private System.Windows.Forms.PictureBox picbThumb;
        private System.Windows.Forms.Panel pnlTopBorder;
        private System.Windows.Forms.Panel pnlItemContainer;
        private System.Windows.Forms.Panel pnlBottomBorder;
        private System.Windows.Forms.Panel pnlNext;
        private System.Windows.Forms.Label lblArrow;
and on my main form i call it like this

 private void showNewsList()
        {
            pnlContent.Controls.Clear();

            ucNewsList nwslList = new ucNewsList();
            pnlContent.Controls.Add(nwslList);
            nwslList.Dock = DockStyle.Fill;
            nwslList.NewsClick += new ucNewsList.NewsClickEvent(ucNewItem_Click);
        }
and finally this is the result



a need this list to have a scroll, its just an user control called newslist with its autoscroll property set to true containing a list of newslistitems user controls, sorry to post a lot of code here but i really need help
juanitoHCPunk  Thursday, July 09, 2009 7:44 PM

You can use google to search for other answers

Custom Search

More Threads

• Can no longer drag Container-type controls with mouse in IDE
• Track the Shift Tab key in Textbox
• frames in windows ?
• How to display combobox with DropDown as DropDownStyle in PropertyGrid
• view designer error - there is no editor available for c:\tmp\windowsapplication1\form1.vb file
• PropertyGrid not showing
• ContainerFilterService implementation
• Component with DataTables. How to impliment?
• Scaling for a Designer surface
• Visual inheritance in derived Forms