hi all,plz tell me how to handle item_Checked event of CHECKEDLISTBOX
here below is the code i've written--but the result is nullregexception
once plz look at my code once, so that i feel u can understand my problem.
i'm filling my checkelist box in pageload using the below code,,
private void frmCustomizeParams_Load(object sender, EventArgs e)
{
blnItemChk = true;
TestingBoard.XMLTasks GetLasersProperties = new TestingBoard.XMLTasks();
string[] LaserChecking = new string[xmltask.GetLaserPropCount("tabular", "property")];
bool[] chkedList = new bool[xmltask.GetLaserPropCount("tabular", "property")];
LaserChecking = GetLasersProperties.GetLaserProp("tabular", "property");
chkedList = GetAllLaserPropchk("tabular", "property");
for (int i = 0; i < LaserChecking.Length; i++)
{
chklstMultipleMdfyTbl.Items.Add(LaserChecking[i], chkedList[i]);
if (chkedList[i])
{
lstChcked.Items.Add(LaserChecking[i]);
}
}
}
}
Here is the ItemCheck Event Handler to Handle the Check/Unchecked Events of itemCheck Event Hanlder, here i am taking a listbox and want to fill selected/deselected values.
here is my Item_Check Event of CheckedListBox
private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (!blnItemChk)
{
}
else
{
if (e.NewValue == CheckState.Unchecked)
{
lstChcked.Items.Remove(chklstMultipleMdfyTbl.SelectedItem.ToString());
}
else if (e.NewValue == CheckState.Checked)
{
lstChcked.Items.Add(chklstMultipleMdfyTbl.SelectedItem.ToString());
}
}
}
Compiler is giving the below exception
{"Object reference not set to an instance of an object."}
Thnx alot for ur kind response till now,
very very sorry to bother u bye byes
prashanth,
Scott LyslePosted Mar 26, 2007, 10:50 PM
Which specific of line of code is identified with your error message? The message is indicating that you are calling an object that has not been instantiated but I can't tell what it is right off hand because I can't see all of your code and I don't what the error is pointing at.
For example, if you declared an object (lets say a sorted list like so):
private SortedList mMyList;
and then, somewhere in your code you tried to add something to that list, you'd get the message that you are showing in your message. The message is telling you that you need to do this:
mMyList = new SortedList();
before you tried to add anything to the list. Find the object in the line that the error message is pointing to and then check your code to make sure that you have actually created an instance of object before attempting to use it.