Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Get the Run time Created controls of ids
 

Get the Run time Created controls of ids

Hi,
I am created rich text boxes at runtime,i want access each rich text box id's ,because i want apply some actions like copy,undo,paste like msword.

Any body can help me
Venkat ------------------------------------------------ -------------------------------------------------------------------------------- Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Venkat
Venkat Chilkuri  Monday, August 24, 2009 2:24 PM

you need to reframe your logic. I didnt get reply notification email for this thread. Its still wrong ? nevermind...

    public partial class Form1 : Form
    {
        private RichTextBox temp;
        private RichTextBox[] boxes=new RichTextBox[10];
        private int xLoc, yLoc;
        private int index;

        public Form1()
        {
            InitializeComponent();
            temp = new RichTextBox();
            temp = richTextBox1;
            richTextBox1.KeyDown += new KeyEventHandler(createRTB);
            xLoc = richTextBox1.Location.X;
            yLoc = richTextBox1.Location.Y;
            index = 0;
            this.AutoScroll = true;

        }

        private void createRTB(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.Equals(Keys.Enter))
            {
                boxes[index] = new RichTextBox();
                boxes[index].Location = new Point(xLoc, yLoc + 170);
                yLoc += 170;
                boxes[index].Name = "myBox" + index.ToString();
                boxes[index].KeyDown += new KeyEventHandler(createRTB);
                boxes[index].MouseClick += new MouseEventHandler(SetCurrentRichTextBox);
                boxes[index].Size = richTextBox1.Size;
                this.Controls.Add(boxes[index]);
                index++;
            }

        }
        private void SetCurrentRichTextBox(object sender, MouseEventArgs e)
        {
            // In some other function if you could use((RichTextBox)sender).Copy();
            // it works
            temp = (RichTextBox)sender;

            
        }
        private void copy()
        {
            temp.Copy();
        }

    }


Thanks

Someone is back..... "OMIE" is back !!! Tell a friend !
Omie  Wednesday, August 26, 2009 3:23 AM
i want access each rich text box id's

what ? is it a array and you want index of selected rich text box.. something like that ?



Thanks

Someone is back..... "OMIE" is back !!! Tell a friend !
Omie  Monday, August 24, 2009 2:40 PM
hi,

below code i am using for get the run time rich text box,but i need particular id,when click on any rich text box.


private

void richTextBox1_KeyDown(object sender, KeyEventArgs e)

{

if (e.KeyCode.Equals(Keys.Enter))

{

//RichTextBox box1 = new RichTextBox();

//richTextBox1.MaximumSize = richTextBox1.Size;

//richTextBox1.SelectionTabs=

//if(richTextBox1.Height==147)

RichTextBox box1 =

new RichTextBox();

box1.Location =

new Point(richTextBox1.Location.X, richTextBox1.Location.Y + 170);

box1.Size = richTextBox1.Size;

box1.KeyDown +=

new KeyEventHandler(box_KeyDown);

//this.Controls.Add(box);

this.Controls.Add(box1);

}

}

void box_KeyDown(object sender, KeyEventArgs e)

{

int i = 170;

int j = Convert.ToInt32(this.Controls.Count.ToString());

int z = i * j;

//RichTextBox box = new RichTextBox();

RichTextBox box1 =

new RichTextBox();

box1.Location =

new Point(richTextBox1.Location.X, richTextBox1.Location.Y + z);

//box.Location = new Point(richTextBox1.Location.X, richTextBox1.Location.Y + 210);

box1.Size = richTextBox1.Size;

box1.KeyDown +=

new KeyEventHandler(box_KeyDown);

//this.Controls.Add(box);

this.Controls.Add(box1);

}


Venkat ------------------------------------------------ -------------------------------------------------------------------------------- Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Venkat
Venkat Chilkuri  Tuesday, August 25, 2009 5:36 AM

you need to reframe your logic. I didnt get reply notification email for this thread. Its still wrong ? nevermind...

    public partial class Form1 : Form
    {
        private RichTextBox temp;
        private RichTextBox[] boxes=new RichTextBox[10];
        private int xLoc, yLoc;
        private int index;

        public Form1()
        {
            InitializeComponent();
            temp = new RichTextBox();
            temp = richTextBox1;
            richTextBox1.KeyDown += new KeyEventHandler(createRTB);
            xLoc = richTextBox1.Location.X;
            yLoc = richTextBox1.Location.Y;
            index = 0;
            this.AutoScroll = true;

        }

        private void createRTB(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.Equals(Keys.Enter))
            {
                boxes[index] = new RichTextBox();
                boxes[index].Location = new Point(xLoc, yLoc + 170);
                yLoc += 170;
                boxes[index].Name = "myBox" + index.ToString();
                boxes[index].KeyDown += new KeyEventHandler(createRTB);
                boxes[index].MouseClick += new MouseEventHandler(SetCurrentRichTextBox);
                boxes[index].Size = richTextBox1.Size;
                this.Controls.Add(boxes[index]);
                index++;
            }

        }
        private void SetCurrentRichTextBox(object sender, MouseEventArgs e)
        {
            // In some other function if you could use((RichTextBox)sender).Copy();
            // it works
            temp = (RichTextBox)sender;

            
        }
        private void copy()
        {
            temp.Copy();
        }

    }


Thanks

Someone is back..... "OMIE" is back !!! Tell a friend !
Omie  Wednesday, August 26, 2009 3:23 AM
Hi,
Thanks for ur reply.

I have one more issue, these run time rich text boxes ,add to panel,

when i give print,then each rich text box fit in print page,

please give code for this

ASAp
Venkat ------------------------------------------------ -------------------------------------------------------------------------------- Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Venkat
Venkat Chilkuri  Wednesday, August 26, 2009 5:53 AM

You can use google to search for other answers

Custom Search

More Threads

• How to get the current selected ContextMenuStripItem in a ContextMenuStrip
• How to serialize your target
• TaskVisionWS - AuthService - System.IO.FileNotFoundException
• Is there an IssueVision guide?
• Unable to Install TV Server on Windows Server 2003 Std.
• moving to the first,previous,next,last records
• Terrarium 1.2: is the battle still fair?
• Error Trying to Install Issue Vision
• Please Help me
• why I can't use my former acount?