WItam!
Chcę usunąć po 1 elemencie z 3 listboxów , ale mam jakiś niezrozumiały dla mnie błąd.
Po kliknięciu w "usuń słówko" wywala to :
I podkreśla w kodzie to co jest na żółto .
Kod :
/*
* Utworzone przez SharpDevelop.
* Użytkownik: Desmont
* Data: 2013-11-21
* Godzina: 14:46
*
* Do zmiany tego szablonu użyj Narzędzia | Opcje | Kodowanie | Edycja Nagłówków Standardowych.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Projekcior_1._
{
/// <summary>
/// Description of Form1.
/// </summary>
public partial class Form1 : Form
{
public Form1()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void RichTextBox1TextChanged(object sender, EventArgs e)
{
}
void Button4Click(object sender, EventArgs e)
{
Close();
}
void Button1Click(object sender, EventArgs e)
{
if(( textBox1.Text=="")||textBox2.Text==""){
MessageBox.Show("Pola wyżej nie mogą być puste !",
"Ważne!",
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1);
}
else{
listBox3.Items.Insert(nr, nr+1);
listBox1.Items.Insert(nr, textBox1.Text);
listBox2.Items.Insert(nr, textBox2.Text);
nr++;
groupBox1.Enabled=true;
}
}
public static int nr=0;
public static int lk=0;
void ListBox1SelectedIndexChanged(object sender, EventArgs e)
{
button2.Enabled=true;
if(listBox2.GetSelected(listBox1.SelectedIndex) == false)
listBox2.SetSelected(listBox1.SelectedIndex,true);
if(listBox3.GetSelected(listBox1.SelectedIndex) == false)
listBox3.SetSelected(listBox1.SelectedIndex,true);
}
void ListBox2SelectedIndexChanged(object sender, EventArgs e)
{
button2.Enabled=true;
if(listBox1.GetSelected(listBox2.SelectedIndex) == false)
listBox1.SetSelected(listBox2.SelectedIndex,true);
if(listBox3.GetSelected(listBox2.SelectedIndex) == false)
listBox3.SetSelected(listBox2.SelectedIndex,true);
}
void ListBox3SelectedIndexChanged(object sender, EventArgs e)
{
button2.Enabled=true;
if(listBox2.GetSelected(listBox3.SelectedIndex) == false)
listBox2.SetSelected(listBox3.SelectedIndex,true);
if(listBox1.GetSelected(listBox3.SelectedIndex) == false)
listBox1.SetSelected(listBox3.SelectedIndex,true);
}
void Button2Click(object sender, EventArgs e)
{
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
listBox2.Items.RemoveAt(listBox1.SelectedIndex);
listBox3.Items.RemoveAt(listBox1.SelectedIndex);
}
void Form1Load(object sender, EventArgs e)
{
lk=0;
nr=0;
}
}
}
Proszę o pomoc.