Windows Develop Bookmark and Share   
 index > Windows Forms General > How to save state to paste button more than one time?
 

How to save state to paste button more than one time?

Hai all
i'm succesfully to create copy and paste button. but i have the next case. i have two context menu. the first context menu in the button that i use to copy paste. in the first context menu when right click it show copy and paste item. in the second contextmenu when i right click it show paste item. the problem is when i use paste item in the second context menu. the button can only paste for one time. so i want the paste item in the second contextmenu to be paste more than one time. how to do that? please answer my question....!!
muhamad nizar iqbal  Thursday, September 24, 2009 3:22 AM
Hi,
i hope it will help you
 Button btn;
        int locX = 100;
        int locY = 0;
         copyToolStripMenuItem_Click(object sender, EventArgs e)
         {
             btn = new Button();
            btn.Name = button1.Name + "Clone";
            btn.Width = button1.Width;
            btn.Text = button1.Text;           
            btn.Location = new Point(button1.Location.X + locX, button1.Location.Y + locY);
         }
        pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
             this.Controls.Add(btn);
            if (this.Width <= locX)
            {
                locX = 0;
                locY = locY + 50;
            }
            else
            {
                locX = locX + 100;
            }

        }


Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
Gnanadurai  Thursday, September 24, 2009 5:20 AM
Hi,
i hope it will help you
 Button btn;
        int locX = 100;
        int locY = 0;
         copyToolStripMenuItem_Click(object sender, EventArgs e)
         {
             btn = new Button();
            btn.Name = button1.Name + "Clone";
            btn.Width = button1.Width;
            btn.Text = button1.Text;           
            btn.Location = new Point(button1.Location.X + locX, button1.Location.Y + locY);
         }
        pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
             this.Controls.Add(btn);
            if (this.Width <= locX)
            {
                locX = 0;
                locY = locY + 50;
            }
            else
            {
                locX = locX + 100;
            }

        }


Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
Gnanadurai  Thursday, September 24, 2009 5:20 AM
i have finished my problem with save state. but iwant ot ask different question. i have the logic to check the button have copied or not. if the button have null value copy item is disable viceversa. but the problem is when i right click with the button value is null the paste item is disable but when i right click for the second time the paste item is enable.Here is my code:

if (contextMenuStrip1.SourceControl is Button && btn == null)
{
//MessageBox.Show("test ");
copyToolStripMenuItem.Enabled = true;
pasteToolStripMenuItem.Enabled = false;
}
else if (contextMenuStrip1.SourceControl is Button && btn != null)
{
//MessageBox.Show("test ");
copyToolStripMenuItem.Enabled = true;
pasteToolStripMenuItem.Enabled = true;
}
else if (contextMenuStrip1.SourceControl is Form1 && btn == null)
{
pasteToolStripMenuItem.Enabled = false;
copyToolStripMenuItem.Visible = false;
}
else if (contextMenuStrip1.SourceControl is Form1 && btn != null)
{
MessageBox.Show("test "+btn);
pasteToolStripMenuItem.Enabled = true;
copyToolStripMenuItem.Visible = false;
}
can you give me advice. because when i right clik the context menu for the second time the paste item is enable in fact i did not copy the button. it should be the paste item in context menu still disable before i click copy.
muhamad nizar iqbal  Thursday, September 24, 2009 6:26 AM
i have finished my problem with save state. but iwant ot ask different question. i have the logic to check the button have copied or not. if the button have null value copy item is disable viceversa. but the problem is when i right click with the button value is null the paste item is disable but when i right click for the second time the paste item is enable.Here is my code:

if (contextMenuStrip1.SourceControl is Button && btn == null)
{
//MessageBox.Show("test ");
copyToolStripMenuItem.Enabled = true;
pasteToolStripMenuItem.Enabled = false;
}
else if (contextMenuStrip1.SourceControl is Button && btn != null)
{
//MessageBox.Show("test ");
copyToolStripMenuItem.Enabled = true;
pasteToolStripMenuItem.Enabled = true;
}
else if (contextMenuStrip1.SourceControl is Form1 && btn == null)
{
pasteToolStripMenuItem.Enabled = false;
copyToolStripMenuItem.Visible = false;
}
else if (contextMenuStrip1.SourceControl is Form1 && btn != null)
{
MessageBox.Show("test "+btn);
pasteToolStripMenuItem.Enabled = true;
copyToolStripMenuItem.Visible = false;
}
can you give me advice. because when i right clik the context menu for the second time the paste item is enable in fact i did not copy the button. it should be the paste item in context menu still disable before i click copy.

i have finis this problem thank you Gnanadurai
muhamad nizar iqbal  Thursday, September 24, 2009 7:21 AM

You can use google to search for other answers

Custom Search

More Threads

• VB.Net Rich TextBox change my text color in middle of one AppendText output!
• Execution Permissions Problem with the .NET Framework
• How to print directly to printer
• Image on custom control
• Threads and Timers
• update rollup 2 for media center HELP
• using List collection
• Hepl : Image in Label
• Dialog Messages
• User control menu merging