I’ve added System.Windows and Microsoft.LightSwitch.Threading; to get access to the clipboard.
When I run this program I get this error: Invalid cross-thread access.
Any ideas for getting the clipboard to work?
partial void btnCopyFaucets_Execute()
{
// Write your code here.
try
{
string CopyText, nManu, nProductCode, nFaucet;
Faucets cpyfaucet = this.FaucetsSearch.SelectedItem;
nManu = Convert.ToString(cpyfaucet.Manufacturer);
nProductCode = Convert.ToString(cpyfaucet.ProductCode);
nFaucet = Convert.ToString(cpyfaucet.Faucet);
CopyText = nManu + " " + nProductCode + " " + nFaucet;
// THIS IS WHERE THE COMPILER IS NOT HAPPY.
Clipboard.SetText(CopyText);
}
catch (Exception damnit)
{
MessageBox.Show(damnit.Message);
}
}
Try to use the Main dispatcher like this:
Maybe if it´s a web app you’ll have permission issues after that.