How to remove items from the CheckListBox (windows application) from
another thread?
I am developing a windows app in which i need to add items in the
checklist-box at run-time from the separate thread, for that i used :
if (chkLBClientsList.InvokeRequired)
chkLBClientsList.Invoke(new
MethodInvoker(delegate{chkLBClientsList.Items.Add(GetHostNameByIpAddress(ipAddress));}));
later in the application i need to remove the items from the checklist-box
and for that i am using same logic :
if (chkLBClientsList.InvokeRequired)
chkLBClientsList.Invoke(new MethodInvoker(delegate {
chkLBClientsList.Items.Remove(GetHostNameByIpAddress(GetIpAddress(client)));
}));
but it's not working....because this statement
chkLBClientsList.InvokeRequired returns FALSE value.
Please tell me how to solve this problem ? Thanks in advance.
No comments:
Post a Comment