Click here to Skip to main content
15,894,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to get picture box image at right side in table lay out in c# at present i am getting image next line of label but i need picture box text beside a label in table lay out panel.Here is my code


PictureBox pb = new PictureBox();
pb.ImageLocation = ../imagesDT/answered.gif
tableLayoutPanel1.Controls.Add(pb);

I am trying to keep image beside the label in table lay out panel but at present getting image below the label
Posted

One of the solutions is this: Use two panels in the same parent container control (Panel of Form); one panel with the property Dock set to DockStyle.Left, another — to DockStyle.Fill (or Right and Fill). This is better than TableLayoutPanel.

Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.forms.dockstyle%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
      //
           // pictureBox1
           //
           this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)
           ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
           this.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.cancel;
           this.pictureBox1.Location = new System.Drawing.Point(1125, 3);
           this.pictureBox1.Name = "pictureBox1";
           this.pictureBox1.Size = new System.Drawing.Size(20, 21);
           this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
           this.pictureBox1.TabIndex = 0;
           this.pictureBox1.TabStop = false;


((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
 
Share this answer
 
Comments
Richard Deeming yesterday    
You've been here plenty long enough to know what happens to people who resurrect ancient questions with unexplained code-dumps!

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