Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i use a treeview in my code and when i click on childnode, a button is created as a tab with selected node value as its text.i want to add close button to every button created.
this is my code:
CSS
<style type="text/css">
    .Initial
 {
   direction:rtl;
   display: block;
   padding: 4px 18px 4px 18px;
   float: right;
   background: url("InitialImage.png") no-repeat right top;
   color: Black;
   font-weight: bold;
 }
 .Initial:hover
 {
   direction:rtl;
   color: White;
   background: url("InitialImage.png") no-repeat right top;
 }
 .Clicked
 {
     direction:rtl;
   float: right;
   display: block;
   background: url("SelectedButton.png") no-repeat right top;
   padding: 4px 18px 4px 18px;
   color: Black;
   font-weight: bold;
   color: White;
 }

C#
public static class Tabbutton
    {
      public static List<Button> myDinamicButtonsListss=new List<Button>();
    }

C#
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
        {
            int flag = 1;
            MainView.Visible = true;
            Button btn = new Button();
            btn.CssClass="Clicked";
            btn.Text = TreeView1.SelectedNode.Value;
            btn.ID = TreeView1.SelectedNode.Target;
            
            foreach (Button b in Tabbutton.myDinamicButtonsListss)
            {
                b.CssClass = "Initial";
            }
            for (int i = 0; i < Tabbutton.myDinamicButtonsListss.Count;i++ )
            {
                if (btn.ID == Tabbutton.myDinamicButtonsListss[i].ID)
                {
                    flag = 0;
                    Tabbutton.myDinamicButtonsListss[i].CssClass = "Clicked";
                    break;
                }
            }
            if (flag == 1)
            {
                btn.CommandArgument = btn.ID;
                btn.Command += new CommandEventHandler(b_Command); //handler
                Tabbutton.myDinamicButtonsListss.Add(btn);
                tabdiv.Controls.Add(btn);
            }
        }
Posted
Comments
ali_heidari_ 6-Aug-13 17:34pm    
add a button with relative position ! or add just one button to close current open tab!

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