Hi, um so I have this checklistbox that has some checkboxes in it using VisualStudio 2005 C#.net and I am making a moble app to allow only one checkbox to be checked at one time. I have gotten the idea of how it should be done but I hit a snag that i did. I know I need to have the checkstate but I dont know how to get it into my code. It is rather dounting that it is. Well here is the code if anyone can help me the problem is down at the bottom that it is with this method
private void deleteToDoItemsView1_Click(object sender, EventArgs e)
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespaceToDoListWM5
{
publicpartialclassForm1 : Form
{
private Model toDoListModel;
publicForm1()
{
InitializeComponent();
}
privatevoidForm1_Load(object sender, EventArgs e)
{
toDoListModel = new Model();
this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData;
this.deleteToDoItemsView1.Visible = true;
this.addToDoItemView1.Visible = false;
}
privatevoidmenuItem2_Click(object sender, EventArgs e)
{
switch (((MenuItem)sender).Text)
{
case"Delete":
{
toDoListModel.DeleteToDoListItems(this.deleteToDoItemsView1.ViewItemsToDelete);
this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData;
this.menuItem1.Text = "Add";
this.menuItem2.Text = "Delete";
this.deleteToDoItemsView1.Visible = true;
this.addToDoItemView1.Visible = false;
break;
}
case"OK":
{
toDoListModel.AddToDoListItem(this.addToDoItemView1.ViewItemToAdd);
this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData;
this.menuItem1.Text = "Add";
this.menuItem2.Text = "Delete";
this.deleteToDoItemsView1.Visible = true;
this.addToDoItemView1.Visible = false;
break;
}
}
}
privatevoidmenuItem1_Click(object sender, EventArgs e)
{
switch (((MenuItem)sender).Text)
{
case"Add":
{
this.addToDoItemView1.ViewData = toDoListModel.ToDoListViewData;
this.menuItem1.Text = "BACK";
this.menuItem2.Text = "OK";
this.deleteToDoItemsView1.Visible = false;
this.addToDoItemView1.Visible = true;
break;
}
case"BACK":
{
this.deleteToDoItemsView1.ViewData = toDoListModel.ToDoListViewData;
this.menuItem1.Text = "Add";
this.menuItem2.Text = "Delete";
this.deleteToDoItemsView1.Visible = true;
this.addToDoItemView1.Visible = false;
break;
}
}
}
//add code here to make sure that one checkbox thingy is check onlyprivatevoiddeleteToDoItemsView1_Click(object sender, EventArgs e)
{
if (CheckState = checked){
this.deleteToDoItemsView1.ViewItemsToDelete.RemoveToDoListRow();
}
}
}
}
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Since I am not familair with the requirements of your application, I don't know if radio buttons would do what you need, but the difference between radio buttons and checkbox buttons is that only one radio button in a group or no radio buttons in that group can be selected at one time; that is how radio buttons work.
Kenshin Hatake6 reputationPosted Apr 9, 2010, 6:05 AM EDT
0
Yes I did look at radiobutton, but in this program has a listbox that the checkboxes are put in that they are. I found that out the other day:) I am trying to figuer out how to make a custom event handler i think to handle the checkstate i think.
Sam HobbsRank #108 · 20.5K reputationPosted Apr 8, 2010, 10:26 PM EDT
Kenshin Hatake6 reputationPosted Apr 9, 2010, 6:05 AM EDT