TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
MetalGearSolid
NA
15
20.9k
Combobox items delete - Error
Jul 30 2012 6:37 PM
private void Form1_Load(object sender, EventArgs e)
{
string[] fp = File.ReadAllLines(@"filepath.txt"); //There are 3 lines in filepath.txt
for (int i = 0; i < fp.Length; i++)
{
comboBox1.Items.Add(fp[i]);
}
}
private void comboBox1_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Delete)
if (comboBox1.SelectedIndex != -1)
comboBox1.Items.RemoveAt(comboBox1.SelectedIndex);
}
catch { }
}
Program gives an error in this line: (When I delete all items from combobox in debug mode, it gives an error)
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new form1());
//InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index
}
}
What is my problem. I can't figure it out...
Reply
Answers (
3
)
Check particular validation from integer Array
How do I do this? I'm stumped :(