Set checkedListBox SelectedIndex without triggering a SelectedIndexChanged event

KKW

Member
Joined
Nov 15, 2013
Messages
7
Programming Experience
10+
Hello all!

I'm trying to figure out how set the SelectedIndex to a -1 without generating an event.

In VB6, I would use the function:

C#:
Call SendMessageBynum(TargetList.hwnd, LB_SETCURSEL, SetValue, 0)

But, I have not been able to find instruction on how to use the VB6 function in C#.

Can someone point me in the right direction?

Thanks!
 
So, looking thru some of the posts on this forum, I came across one that referred to the use of DllImport.
Upon further investigation, I discovered that I could in fact use the SendMessageByNum function!
Actually, it worked out that it is called by it's alias - SendMessageA.
Here's my implementation:
C#:
[COLOR=#0000ff][COLOR=#0000ff]public class [/COLOR][/COLOR]Bynum
{
   [DllImport("user32.dll")]
      [COLOR=#0000ff][COLOR=#0000ff]public static extern [/COLOR][/COLOR][COLOR=#2b91af][COLOR=#2b91af]IntPtr[/COLOR][/COLOR] SendMessageA([COLOR=#2b91af][COLOR=#2b91af]IntPtr[/COLOR][/COLOR] hWnd, [COLOR=#2b91af][COLOR=#2b91af]UInt32[/COLOR][/COLOR] wMsg, [COLOR=#2b91af][COLOR=#2b91af]Int32[/COLOR][/COLOR] wParam, [COLOR=#2b91af][COLOR=#2b91af]Int32[/COLOR][/COLOR] lParam);
      [COLOR=#0000ff][COLOR=#0000ff]public const int[/COLOR][/COLOR] LB_SETCURSEL = 0x0186;
}

Usage:
C#:
ByNum.SendMessageA(checkedListBox1.Handle, 0x0186, -1, 0);
I used the value of LB_SETCURSEL rather than the name...
 
Back
Top Bottom