TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sharrif Hussain
NA
45
1.5k
TableLayoutpanel and picturebox in window form application
Dec 4 2017 7:57 AM
Hello tell me how to add picture box in runtime using c# me attach pic and me want every column add pic so tell me
public void GetData()
{
DataTable dt = new DataTable();
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/Sharrif Hussain/Documents/Sharo1.accdb");
con.Open();
string q = "Select Award1,Award2,Award3,Award4,Award5,Award6,Imagepath from Table2";
OleDbCommand cmd = new OleDbCommand(q, con);
// OleDbDataReader oDr = cmd.ExecuteReader();
OleDbDataAdapter oDA = new OleDbDataAdapter(cmd);
oDA.Fill(dt);
tableLayoutPanel2.RowCount = dt.Rows.Count - 1;
tableLayoutPanel2.ColumnCount = 6;
int i = 0;
string AwardText1 = dt.Rows[0]["Award1"].ToString();
string AwardText2 = dt.Rows[0]["Award2"].ToString();
string AwardText3 = dt.Rows[0]["Award3"].ToString();
string AwardText4 = dt.Rows[0]["Award4"].ToString();
string AwardText5 = dt.Rows[0]["Award5"].ToString();
string AwardText6 = dt.Rows[0]["Award6"].ToString();
string Imagepath = dt.Rows[0]["Imagepath"].ToString();
//tableLayoutPanel2.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;
tableLayoutPanel2.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
tableLayoutPanel2.Controls.Clear();
tableLayoutPanel2.ColumnStyles.Clear();
tableLayoutPanel2.RowStyles.Clear();
for (int x = 0; x < tableLayoutPanel2.ColumnCount; x++)
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle() { Width = 33, SizeType = SizeType.Percent });
for (int x = 0; x < tableLayoutPanel2.RowCount; x++)
tableLayoutPanel2.RowStyles.Add(new RowStyle() { Height = 20, SizeType = SizeType.Percent });
for (int k = 1; k < dt.Rows.Count; k++)
{
i = i + 1;
Label lbl1 = new Label()
{
Text = string.Concat(AwardText1, dt.Rows[k]["Award1"].ToString()),
Size = new Size(174, 17)
};
////var picture = new PictureBox
////{
//// Name = "pictureBox",
//// Size = new Size(16, 16),
//// Location = new Point(100, 100),
//// Image = Image.FromFile("C:/Users/Sharrif Hussain/documents/visual studio 2012/Projects/WindowsFormsApplication1/WindowsFormsApplication1/Resources/award1.jpg"),
////};
////this.Controls.Add(picture);
PictureBox picture1 = new PictureBox
{
Name = "pictureBox",
Size = new Size(200, 200),
Location = new Point(i * 316, 1),
BorderStyle = BorderStyle.FixedSingle,
SizeMode = PictureBoxSizeMode.Zoom,
};
picture1.ImageLocation = dt.Rows[k]["Imagepath"].ToString();
Label lbl2 = new Label()
{
Text = string.Concat(AwardText2, dt.Rows[k]["Award2"].ToString()),
Size = new Size(174, 17)
};
Label lbl3 = new Label()
{
Text = string.Concat(AwardText3, dt.Rows[k]["Award3"].ToString()),
Size = new Size(174, 17)
};
Label lbl4 = new Label()
{
Text = string.Concat(AwardText4, dt.Rows[k]["Award4"].ToString()),
Size = new Size(174, 17)
};
Label lbl5 = new Label()
{
Text = string.Concat(AwardText5, dt.Rows[k]["Award5"].ToString()),
Size = new Size(174, 17)
};
Label lbl6 = new Label()
{
Text = string.Concat(AwardText6, dt.Rows[k]["Award6"].ToString()),
Size = new Size(174, 17)
};
tableLayoutPanel2.Controls.Add(lbl1);
tableLayoutPanel2.SetRow(lbl1, i);
tableLayoutPanel2.Controls.Add(picture1);
tableLayoutPanel2.SetRow(picture1, i);
tableLayoutPanel2.Controls.Add(lbl2);
tableLayoutPanel2.SetRow(lbl2, i);
tableLayoutPanel2.Controls.Add(lbl3);
tableLayoutPanel2.SetRow(lbl3, i);
tableLayoutPanel2.Controls.Add(lbl4);
tableLayoutPanel2.SetRow(lbl4, i);
tableLayoutPanel2.Controls.Add(lbl5);
tableLayoutPanel2.SetRow(lbl5, i);
tableLayoutPanel2.Controls.Add(lbl6);
tableLayoutPanel2.SetRow(lbl6, i);
}
}
Reply
Answers (
0
)
How can i Sum value from Data Table Distinct Value
function with argument and return value in c(Febonacci)