hi.. i tried to make a array list of 5 element in which recent 5 clipboard text is copied
but i am not able to do this every time clipboard text overwrites the previous one and in first array element
and prints only the last one i want to print all how can i do this.
if my case is possible thn please give me some solution
Loading

Suthish NairRank #92 · 22.8K reputationPosted Oct 24, 2010, 12:10 AM EDT
shruti sinha5 reputationPosted Oct 24, 2010, 4:30 AM EDT
Sam HobbsRank #108 · 20.5K reputationPosted Oct 24, 2010, 6:41 PM EDT
I am sorry, but the question is not clear. I don't understand what you mean by "recent 5 clipboard text" and I am not sure what you mean by array. I have no idea what you mean by "clipboard text overwrites the previous one".
shruti sinha5 reputationPosted Nov 8, 2010, 7:01 PM EST
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
const int MaxItems = 5;
static readonly List
[DllImport("user32.dll")]
static extern IntPtr GetOpenClipboardWindow();
public static void SaveClipboard()
{
ClipboardData.Add(Clipboard.GetText());
if (ClipboardData.Count > MaxItems) ClipboardData.RemoveAt(0);
}
private void button1_Click(object sender, EventArgs e)
{
string str;
for (int i = 0; i < 3; i++)
{
//Clipboard.SetText(i.ToString());
str = Clipboard.GetText();
SaveClipboard();
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
foreach (var s in ClipboardData)
{
MessageBox.Show(s);
}
}
}
}
Suthish NairRank #92 · 22.8K reputationPosted Nov 8, 2010, 7:25 PM EST
try saving to a text file, later retrive...
Sam HobbsRank #108 · 20.5K reputationPosted Nov 9, 2010, 12:03 AM EST