Click here to Skip to main content
15,891,864 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cant open a form after closing from toolbar Pin
tampasounds5-Mar-07 19:42
tampasounds5-Mar-07 19:42 
GeneralRe: Cant open a form after closing from toolbar Pin
Glen Harvy5-Mar-07 21:33
Glen Harvy5-Mar-07 21:33 
Questionhiding listview items Pin
Keshav V. Kamat5-Mar-07 16:34
Keshav V. Kamat5-Mar-07 16:34 
AnswerRe: hiding listview items Pin
Glen Harvy5-Mar-07 17:06
Glen Harvy5-Mar-07 17:06 
GeneralRe: hiding listview items Pin
Mundo Cani5-Mar-07 17:16
Mundo Cani5-Mar-07 17:16 
GeneralRe: hiding listview items Pin
Glen Harvy5-Mar-07 17:27
Glen Harvy5-Mar-07 17:27 
GeneralRe: hiding listview items Pin
Keshav V. Kamat5-Mar-07 17:24
Keshav V. Kamat5-Mar-07 17:24 
AnswerRe: hiding listview items Pin
Mundo Cani5-Mar-07 17:09
Mundo Cani5-Mar-07 17:09 
Instead of managing the listbox's items directly, you can databind the listbox to a list[string]. You can maintain a Dictionary[string, list[string]] that keeps track of all the views you want to show, then bind the listbox to the corresponding list<string>. Like this:

namespace ListBoxTest
{
public partial class ListBoxDataBinding : Form
{
Dictionary[string, List[string]] myLists = new Dictionary[string, List[string]]();

public ListBoxDataBinding()
{
InitializeComponent();

// Create a list of colors and add it to the dictionary
List[string] colors = new List[string]();
colors.Add("red");
colors.Add("green");
colors.Add("blue");
myLists.Add("colors", colors);

// Create a list of flavors and add it to the dictionary
List[string] flavors = new List[string]();
flavors.Add("vanilla");
flavors.Add("chocolate");
flavors.Add("strawberry");
myLists.Add("flavors", flavors);
}

// The user clicked the button that will cause the listbox to show flavors
private void btnFlavors_Click(object sender, EventArgs e)
{
// bind the listbox to the list of flavors
this.filteredListBox.DataSource = this.myLists["flavors"];
}

// The user clicked the button that will cause the listbox to show colors
private void btnColors_Click(object sender, EventArgs e)
{
// bind the listbox to the list of colors
this.filteredListBox.DataSource = this.myLists["colors"];
}
}
}

Just an idea.

BTW, when using the generic List and Dictionary types, you'll need to replace the '[' and ']' with '<' and '>'. Anyone know how to escape the '<>' characters?

Ian

GeneralRe: hiding listview items Pin
Keshav V. Kamat5-Mar-07 17:22
Keshav V. Kamat5-Mar-07 17:22 
QuestionRetrieving values from DataTable Pin
myNameIsRon5-Mar-07 15:49
myNameIsRon5-Mar-07 15:49 
AnswerRe: Retrieving values from DataTable Pin
Glen Harvy5-Mar-07 16:13
Glen Harvy5-Mar-07 16:13 
GeneralRe: Retrieving values from DataTable Pin
myNameIsRon6-Mar-07 18:56
myNameIsRon6-Mar-07 18:56 
QuestionCollision Detection in DirectX Pin
Koocurrent5-Mar-07 14:33
Koocurrent5-Mar-07 14:33 
QuestionObject cannot be cast from DBNull to other types Pin
ujupanmester5-Mar-07 13:07
ujupanmester5-Mar-07 13:07 
AnswerRe: Object cannot be cast from DBNull to other types Pin
Colin Angus Mackay5-Mar-07 13:48
Colin Angus Mackay5-Mar-07 13:48 
AnswerRe: Object cannot be cast from DBNull to other types Pin
Glen Harvy5-Mar-07 16:04
Glen Harvy5-Mar-07 16:04 
AnswerRe: Object cannot be cast from DBNull to other types Pin
sam#5-Mar-07 18:27
sam#5-Mar-07 18:27 
GeneralRe: Object cannot be cast from DBNull to other types Pin
ujupanmester6-Mar-07 9:34
ujupanmester6-Mar-07 9:34 
GeneralRe: Object cannot be cast from DBNull to other types Pin
ujupanmester6-Mar-07 9:54
ujupanmester6-Mar-07 9:54 
Questionsimple radio button question Pin
dino20945-Mar-07 13:00
dino20945-Mar-07 13:00 
AnswerRe: simple radio button question Pin
Luc Pattyn5-Mar-07 13:21
sitebuilderLuc Pattyn5-Mar-07 13:21 
AnswerRe: simple radio button question Pin
Koocurrent5-Mar-07 15:02
Koocurrent5-Mar-07 15:02 
AnswerRe: simple radio button question Pin
engsrini5-Mar-07 18:42
engsrini5-Mar-07 18:42 
QuestionWindows Service Pin
Darkness845-Mar-07 12:41
Darkness845-Mar-07 12:41 
AnswerRe: Windows Service Pin
Luc Pattyn5-Mar-07 13:22
sitebuilderLuc Pattyn5-Mar-07 13:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.