Bluewolf Bluewolf - 4 months ago 10
C# Question

c# MessageBox how to make the mouse go automatically to the button no

I need help I don't know I do to delete an item from the listbox by double click the item I have just started like 1 hour ago so I don't have code that can help. I didn't find anything on interned that could help me. if you know how to do this or a tutorial pleas comment that

UPDATE 1
this is all the code i have

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;


namespace Scratch
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

//close form
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}

//btnWhenClicked
private void btnWhenStart_Click(object sender, EventArgs e)
{
ListItemsBox.Items.Add("When Start");
btnWhenStart.Hide();
string path = @"C:\Users\Estagio\Desktop\MyTest.txt";

//Create And Write File
if (!File.Exists(path))
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("using System;");
}
}


}

//delete ListItemsBox Selected Item
private void ListItemsBox_DoubleClick(object sender, EventArgs e)
{

}


Idont know if this can help you

Update2
I know there is a double click event i just dont know how to delete a item when double click

Update3
I cant do more question so i ask here.
I created a messagebox and when the messagebox popup the muse go to the button yes automatically is there any way to make it go to the no button i tried to find on the internet but i didnt find anything
this s the code

private void ListItemsBox_DoubleClick(object sender, EventArgs e)
{
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)
{

}

Answer
private void ListItemsBox_DoubleClick(object sender, EventArgs e){
    ListItemsBox.Items.Remove(ListItemsBox.SelectedItem);
}