thanks Gnanadurai for your quick reply.
You mean i should calculate the new Y location for my next runtime control and subtract it to previously added runtime control? Or you mean to get the Y location of the Form & subtract from my next runtime control?
Please make it clear,thanks.
My whole code to create the runtime controls is here:
//------------Start Code------------
public bool addNewControls(string senderOrReciver, string fromUser, string fileName, string ToUser)
{
try
{
FontFamily ff = new FontFamily("Verdana");
float size = float.Parse("8.25");
FontStyle objFS = FontStyle.Bold;
Font myFont = new Font(ff, size, objFS);
string dname;
string dnameCancel;
if (senderOrReciver.Trim().ToString() == "Sender :")
{
dname = fromUser + fileName;
dnameCancel = fromUser +
"=" + ToUser + "=" + fileName;
}
else
{
dname = ToUser + fileName;
dnameCancel =
"Rec" + fromUser + "=" + ToUser + "=" + fileName;
}
Label l = new Label();
l.Name =
"fileName" + "_" + dname;
l.Font = myFont;
//l.ForeColor = Color.White;
l.Text =
"File Name : " + fileName;
l.Location =
new Point(202, FileNameY + y);
l.Width = 200;
l.BackColor =
Color.Transparent;
this.Controls.Add(l);
Label l1 = new Label();
l1 =
new Label();
l1.Name =
"Sender" + "_" + dname;
if (senderOrReciver == "Sender : ")
{
l1.Text = senderOrReciver + fromUser;
}
else
{
l1.Text = senderOrReciver + ToUser;
}
//l1.ForeColor = Color.White;
//l1.Text = "Sender : " + fromUser;
l1.Location =
new Point(28, senderNameY + y);
l1.Font = myFont;
//l1.BackColor = Color.Transparent;
l1.Width = 200;
this.Controls.Add(l1);
Label l2 = new Label();
l2 =
new Label();
l2.Name =
"display" + "_" + dname;
l2.Text =
"";
l2.Location =
new Point(27, displayAndButton + y);
l2.Font = myFont;
//l2.BackColor = Color.Transparent;
l2.Width = 200;
this.Controls.Add(l2);
ProgressBar p = new ProgressBar();
p.Name =
"progressBar" + "_" + dname;
p.Location =
new Point(30, progressBarY + y);
p.Height = 15;
p.Width = 463;
p.Maximum = 100;
//p.BackColor = Color.Transparent;
this.Controls.Add(p);
Button b = new Button();
b.Name =
"cancel" + "_" + dnameCancel;
b.Location =
new Point(385, displayAndButton + y);
b.Text =
"Cancel";
//b.BackColor = Color.Transparent;
//b.Click += new EventHandler(picBtnCancel_Click);
b.Click +=
new EventHandler(b_Click);
this.Controls.Add(b);
//fileID = fileID + 1;
//Add File Open Button
Button ob = new Button();
ob.Name =
"Open" + "_" + dname;
ob.Location =
new Point(200, displayAndButton + y);
ob.Text =
"Open File";
//ob.BackColor = Color.Transparent;
ob.Visible =
false;
ob.Click +=
new EventHandler(ob_Click);
this.Controls.Add(ob);
//End File Open Button
y = y + 90;
return true;
}
catch (Exception exc)
{
return false;
}
// }
}
//---End Code---
Waiting for you kind reply,
Thanks
maiqbal