views:

28

answers:

3

Hi,

How to get the handle of a ListBox control in VB.NET 2005?

I am using

Dim i_Handle As ListBox

i_Handle = ListBox1.Handle

But this is not working

A: 

Hi,

Handle is an IntPrt (A handle is just a 32-bit integer).

Thomas M.
sorry, can you please be clear? how should I get the hanlde in this case?
JPro
+1  A: 

You're creating a new ListBox and setting it to be the value of ListBox1.Handle - but ListBox1.Handle returns an IntPrt type - an integer.

 Dim listBoxHandle As IntPtr

 listBoxHandle = ListBox1.Handle
 MessageBox.Show(listBoxHandle) // You'll see numbers.
Daniel May
A: 

Instead of ListBox you must use IntPtr :

Dim i_Handle As IntPtr

i_Handle = ListBox1.Handle
Thomas M.
Thank you. But why did your first post to -1?
JPro
I don't know , first post hazing perhaps :)
Thomas M.