Windows Develop Bookmark and Share   
 index > Windows Forms General > ComboBox list(simple question)
 

ComboBox list(simple question)

Hey,

How do you have this code work in a combobox?

if (toolStripComboBox1.Text == "Add Bookmark")

{

Bookmark theNewBookmarkToAdd = new Bookmark(this.URLtextbox.Text, "URL title: " + this.toolStripTextBox1.Text);

this.theBookmarks.DoAddBookmark(theNewBookmarkToAdd);

toolStrip2.Visible = false;

}

else if (toolStripComboBox1.Text == "Cancel")

{

toolStrip2.Visible = false;

}

So once you select Add Bookmark OR Cancel then it will prosses this code?

I am not using any buttons or anything just the combobox for selecting...I have tryed 3 ways but 0 worked...

progames25  Saturday, July 29, 2006 1:49 AM

handle Seleted family events like TextChanged or SelectedIndexChanged so you can handle one of this events like



private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (toolStripComboBox1.Text == "Add Bookmark")
{
Bookmark theNewBookmarkToAdd = new Bookmark(this.URLtextbox.Text, "URL title: " + this.toolStripTextBox1.Text);
this.theBookmarks.DoAddBookmark(theNewBookmarkToAdd);
toolStrip2.Visible = false;
}
else if (toolStripComboBox1.Text == "Cancel")
{
toolStrip2.Visible = false;
}

}

 

Mohammad Al Husseiny  Saturday, July 29, 2006 8:04 AM

handle Seleted family events like TextChanged or SelectedIndexChanged so you can handle one of this events like



private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (toolStripComboBox1.Text == "Add Bookmark")
{
Bookmark theNewBookmarkToAdd = new Bookmark(this.URLtextbox.Text, "URL title: " + this.toolStripTextBox1.Text);
this.theBookmarks.DoAddBookmark(theNewBookmarkToAdd);
toolStrip2.Visible = false;
}
else if (toolStripComboBox1.Text == "Cancel")
{
toolStrip2.Visible = false;
}

}

 

Mohammad Al Husseiny  Saturday, July 29, 2006 8:04 AM

Thanks,

it works :)

progames25  Saturday, July 29, 2006 6:06 PM

You can use google to search for other answers

Custom Search

More Threads

• Enable / disable datagridview depending on column data of another datagridview
• UserControl as a ListViewItem
• displaying custom control in datagridview column
• Funky Error with ShowDialog() Call
• i wanna make a progressbar for the loading of the form
• Testing scalar query for NULL
• simple application and 300MB reserved memory
• Printing a template in ms word using vs2008
• ID Number for Rich Text Format?
• MDI parent+MDI child form with an issue?????