private void ViewAllRoom_Load(object sender, EventArgs e)
{
//This Is Parent Node
TreeNode MainNode = new TreeNode();
MainNode.NodeFont = new Font("Microsoft Sans Serif", 10);
MainNode.Name = "MainName";
MainNode.Text = "All Rooms";
MainNode.ForeColor = Color.Red;
this.treeView1.Nodes.Add(MainNode);
//Next add child Node
ds = da.GetDataTable("SELECT RName FROM RTypeCreation");
foreach (DataRow Parentrow in ds.Tables[0].Rows)
{
TreeNode treenode = new TreeNode((string)Parentrow["RName"]);
MainNode.Nodes.Add(treenode);
treenode.NodeFont = new Font("Microsoft Sans Serif", 10);
treenode.ForeColor = Color.Tan;
}
Friday, January 28, 2011
Monday, January 17, 2011
Create Button at Run Time In C #
for (int i = 0; i < 10; i++)
{
obj = new Button();
obj.Location = new Point(bt, 80);
newname = (btn + i).ToString();
obj.Name = "Table";
obj.Text = newname;
obj.Height = 50;
obj.Width = 80;
obj.Click += new EventHandler(obj_Click);
this.Controls.Add(obj);
bt += 90;
}
{
obj = new Button();
obj.Location = new Point(bt, 80);
newname = (btn + i).ToString();
obj.Name = "Table";
obj.Text = newname;
obj.Height = 50;
obj.Width = 80;
obj.Click += new EventHandler(obj_Click);
this.Controls.Add(obj);
bt += 90;
}
Run Time Created Button Color Change In C#
public void BtnColourChg()
{
DataAccess da = new DataAccess();
try
{
da.OpenConnection();
SqlDataReader dr = da.ExecuteReader("Select tableno from billtotal where status=1");
while (dr.Read())
{
foreach (Control item in this.Controls)
{
if (item is Button)
{
Button b = (Button)item;
if (b.Text == dr[0].ToString())
{
b.BackColor = System.Drawing.Color.Red;
}
}
}
}
}
catch (Exception ex) { }
finally { da.CloseConnection(); }
}
{
DataAccess da = new DataAccess();
try
{
da.OpenConnection();
SqlDataReader dr = da.ExecuteReader("Select tableno from billtotal where status=1");
while (dr.Read())
{
foreach (Control item in this.Controls)
{
if (item is Button)
{
Button b = (Button)item;
if (b.Text == dr[0].ToString())
{
b.BackColor = System.Drawing.Color.Red;
}
}
}
}
}
catch (Exception ex) { }
finally { da.CloseConnection(); }
}
Subscribe to:
Posts (Atom)