Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

C# - Dynamically add and remvoe iteams from DataGridView and "Smart Events"

$
0
0

Hi

In shortly my problem is how to implement "Send to" code (right click on file on windows)


I have a program with data grid view that also contian a log file name (I know the path for each file)

I want to add to my pop-up menu Copy options to Desktop and Disk on Key drivers.

My pop-up meun seems like this:

   View log

   Open file location

   ------------------

   Copy to ->

   ...

So I want:

  1. to add a list with "Desktop" and all removable drivers under "Copy to" sub menu (and to remove removable drivers that the user eject them)

  1.1 I found the code that detect if removable driver plug in the computer:

private void menu_PopUp_Opening(object sender, CancelEventArgs e)
{
	// Need to remove all removable drivers first --> How to do ?

	// to update the USB drivers when opening new pop up menu
	DriveInfo[] ListDrives = DriveInfo.GetDrives();
	foreach (DriveInfo Drive in ListDrives)
	{
		if (Drive.DriveType == DriveType.Removable)
		{
			// add to popup menu: http://stackoverflow.com/questions/5868446/how-to-add-sub-menu-items-in-contextmenustrip-using-c4-0
			(menu_PopUp.Items[3] as ToolStripMenuItem).DropDownItems.Add(Drive.Name + " (" + Drive.VolumeLabel + ")");
		}
	}

}

2. As I say I want to copy the file to the removable driver, So How can I add "dynamically event" - I meaning - if the user plug in 4 Disk On Key drivers I have new 4 lines under "Copy to" sub menu, So I need click event for each line (Removable driver) to copy the file to the true driver...

Thank you for any help !







Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>