tags:

views:

637

answers:

1

Hello , i have the following situation : with my function i get an XML file , parse it and add group box with image and a text box for every post node in the XML file , And for each group box i assign name and toolstrip menu which has a dinamicly added 1 item the thing i want to do is this - when clicked this item ( lets say the item has name Jeff) so .. when i press the menu item Jeff to add text to a text box ( the text is "@Jeff) . as u can see i managed to make the name adding in the toolstripmenu but i cant make it when i clic to add the name to the text box for each person

and here is my function so you could see what im talking about

 public void parseXmlatme()

    {


        string sUser, sUrl;

        string avatar;
        sUser = Settings.Default.user;
        AtMeFlowLayoutPanel.Controls.Clear();
        sUrl = "http://edno23.com/api/xml/get.php?username=" + sUser + "&type=posts_mention_me";
        rssReader = new XmlTextReader(sUrl.ToString());
        rssDoc = new XmlDocument();
        rssDoc.Load(rssReader);

        for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
        {
            if (rssDoc.ChildNodes[i].Name == "edno23")
            {
                nodeRss = rssDoc.ChildNodes[i];
            }
        }

        for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
        {
            if (nodeRss.ChildNodes[i].Name == "posts")
            {
                nodeChannel = nodeRss.ChildNodes[i];
            }
        }

        for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
        {
            if (nodeChannel.ChildNodes[i].Name == "post")
            {
                nodeItem = nodeChannel.ChildNodes[i];
                string C;
                C = nodeItem["user_from"].InnerText;
                avatar = nodeItem["user_from_avatar"].InnerText; ;
                // 
                // groupBox1
                // 
                GroupBox grpBox = new GroupBox();
                TextBox txtBox = new TextBox();
                PictureBox picBox = new PictureBox();
                ContextMenuStrip  rightMenu = new ContextMenuStrip();
                ToolStripMenuItem atMe = new ToolStripMenuItem();

                // 
                // rightMenu
                // 
                rightMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                atMe});
                rightMenu.Name = "rightclick";
                rightMenu.Size = new System.Drawing.Size(153, 70);
                // 
                // toolStripMenuItem2
                // 
                atMe.Name = "toolStripMenuItem2";
                atMe.Size = new System.Drawing.Size(152, 22);
                atMe.Text = "@"+C;
                name = C;
                atMe.Click += atMe_Click;



                 ////
                grpBox.Location = new System.Drawing.Point(3, 3);
                grpBox.Name = "grpBoxatme" + i;
                grpBox.Size = new System.Drawing.Size(301, 73);
                grpBox.TabIndex = 0;
                grpBox.TabStop = false;
                grpBox.Text = C;
                grpBox.ContextMenuStrip = rightMenu;
               // rightMenu.Items.Add(C);
                // txtbox
                txtBox.BackColor = System.Drawing.SystemColors.ControlLightLight;
                txtBox.Location = new System.Drawing.Point(59, 16);
                txtBox.Multiline = true;
                txtBox.Name = "txtBoxatme" + i;
                txtBox.ReadOnly = true;
                txtBox.Size = new System.Drawing.Size(235, 49);
                txtBox.TabIndex = 2;
                txtBox.Text = nodeItem["message"].InnerText;

                //pic box
                picBox.Dock = System.Windows.Forms.DockStyle.Left;
                picBox.ImageLocation = "http://img.edno23.com/avatars/thumbs/" + avatar;
                picBox.Location = new System.Drawing.Point(3, 16);
                picBox.Name = "pictureBoxatme" + i;
                picBox.Size = new System.Drawing.Size(50, 54);
                picBox.TabIndex = 0;
                picBox.TabStop = false;

                AtMeFlowLayoutPanel.Controls.Add(picBox);
                AtMeFlowLayoutPanel.Controls.Add(grpBox);
                grpBox.Controls.Add(picBox);
                grpBox.Controls.Add(txtBox);
            }
        }




    }

`

Thanks in advance .

A: 

here is a clue that helped me solve the question.

using System;

using System.Drawing;

using System.Windows.Forms;

    public partial class Form1 : Form
    {
        public Button sb;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int x = 0; x < 10; x++)
            {
                sb = new Button();
                sb.Size = new Size(25, 25);
                sb.Location = new Point(x * 25, 10);
                sb.Visible = true;
                sb.Text = x.ToString();
                sb.Click += new EventHandler(sb_Click);
                Controls.Add(sb);
            }
        }

        private void sb_Click(object sender, System.EventArgs e)
        {
            Button sb = sender as Button;
            this.Text = sb.Text;
        }
    }
Aviatrix