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