-1
I want when I double click on the listbox item, when start it do an action, when I double click on any other item it do another action.
Code:
//btnWhenClicked
private void btnWhenStart_Click(object sender, EventArgs e)
{
ListItemsBox.Items.Add("When Start"); //é este iteam que eu quero que detect
btnWhenStart.Hide();
string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + "MyTest.txt";
//Create And Write File
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("using System;");
sw.WriteLine("using System.Collections.Generic;");
sw.WriteLine("using System.Linq;");
sw.WriteLine("using System.Text;");
sw.WriteLine("using System.Threading.Tasks;");
sw.WriteLine("\r\n namespace CMD");
sw.WriteLine("{");
sw.WriteLine(" class Program");
sw.WriteLine(" {");
sw.WriteLine(" static void Main(string[] args)");
sw.WriteLine(" {");
sw.Close();
}
}
}
//delete ListItemsBox Selected Item
private void ListItemsBox_DoubleClick(object sender, EventArgs e)
{
string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + "MyTest.txt";
DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this item?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
ListItemsBox.Items.Remove(ListItemsBox.SelectedItem);
}
else if (dialogResult == DialogResult.No)
{
}
}