Sending multiple items to the clipboard?
-
Hi, I am trying to send a list of urls to the clipboard from my app which will be caught by a download manager. I have got it to work with a single url no problem, but when I select multiple items (in a ListView) the app crashes after the first URL has been sent to the clipboard. This is the code I am using; public void mnuDownloadItem_Click(object sender, System.EventArgs e) { // Some variable declarations int i = 0; String sCurrentURL = ""; // This stops it crashing when the listView is empty if (listView1.SelectedItems.Count != 0) { for(i=0; i < listView1.SelectedItems.Count; i++) { sCurrentURL = listView1.SelectedItems[i].Tag.ToString(); Clipboard.SetDataObject(sCurrentURL); } } } Would appreciate any help with this. Thanks Paul Mason
-
Hi, I am trying to send a list of urls to the clipboard from my app which will be caught by a download manager. I have got it to work with a single url no problem, but when I select multiple items (in a ListView) the app crashes after the first URL has been sent to the clipboard. This is the code I am using; public void mnuDownloadItem_Click(object sender, System.EventArgs e) { // Some variable declarations int i = 0; String sCurrentURL = ""; // This stops it crashing when the listView is empty if (listView1.SelectedItems.Count != 0) { for(i=0; i < listView1.SelectedItems.Count; i++) { sCurrentURL = listView1.SelectedItems[i].Tag.ToString(); Clipboard.SetDataObject(sCurrentURL); } } } Would appreciate any help with this. Thanks Paul Mason
What exception is being thrown? I see nothing wrong with your code as is; so the exception would help diagnose the problem :) James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
-
What exception is being thrown? I see nothing wrong with your code as is; so the exception would help diagnose the problem :) James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972
Hi, First thanks for the reply! Secondly after some more experimenting I've found it isnt actually my application raising the exception, its external and is in the download manager (Flashget) which is catching the clipboard copies. So Im wondering if its perhaps sending the copies too quickly for Flashget to catch them, would there be any way I can insert a short pause to test that? Im sure its now pasting OK as I checked the last URL on the clipboard against my ListView and it matched. Thanks Again Paul Mason