Use ContextMenuStrip instead of ContextMenu

This commit is contained in:
Jaex 2019-12-03 23:11:35 +03:00
parent a149c608b7
commit 1b00fb0538
3 changed files with 9 additions and 6 deletions

View file

@ -297,7 +297,7 @@ internal class Resources {
}
/// <summary>
/// Looks up a localized string similar to More info.
/// Looks up a localized string similar to More info....
/// </summary>
internal static string HistoryItemManager_InitializeComponent_More_info {
get {

View file

@ -182,7 +182,7 @@
<value>Open</value>
</data>
<data name="HistoryItemManager_InitializeComponent_More_info" xml:space="preserve">
<value>More info</value>
<value>More info...</value>
</data>
<data name="HistoryItemManager_InitializeComponent_HTML_link" xml:space="preserve">
<value>HTML link</value>

View file

@ -55,10 +55,11 @@ public ObjectListView()
MultiSelect = false;
Columns.Add(Resources.ObjectListView_ObjectListView_Name, 125);
Columns.Add(Resources.ObjectListView_ObjectListView_Value, 300);
ContextMenu contextMenu = new ContextMenu();
contextMenu.MenuItems.Add(Resources.ObjectListView_ObjectListView_Copy_name).Click += PropertyListView_Click_Name;
contextMenu.MenuItems.Add(Resources.ObjectListView_ObjectListView_Copy_value).Click += PropertyListView_Click_Value;
ContextMenu = contextMenu;
ContextMenuStrip cms = new ContextMenuStrip();
cms.ShowImageMargin = false;
cms.Items.Add(Resources.ObjectListView_ObjectListView_Copy_name).Click += PropertyListView_Click_Name;
cms.Items.Add(Resources.ObjectListView_ObjectListView_Copy_value).Click += PropertyListView_Click_Value;
ContextMenuStrip = cms;
}
private void PropertyListView_Click_Name(object sender, EventArgs e)
@ -66,6 +67,7 @@ private void PropertyListView_Click_Name(object sender, EventArgs e)
if (SelectedItems.Count > 0)
{
string text = SelectedItems[0].Text;
if (!string.IsNullOrEmpty(text))
{
ClipboardHelpers.CopyText(text);
@ -78,6 +80,7 @@ private void PropertyListView_Click_Value(object sender, EventArgs e)
if (SelectedItems.Count > 0)
{
string text = SelectedItems[0].SubItems[1].Text;
if (!string.IsNullOrEmpty(text))
{
ClipboardHelpers.CopyText(text);