如何在vb.net 2005中获取列表框的句柄

时间:2009-12-23 13:54:23

标签: vb.net winforms

如何在VB.NET 2005中获取ListBox控件的句柄?

我正在使用

Dim i_Handle As ListBox

i_Handle = ListBox1.Handle

但这不起作用

3 个答案:

答案 0 :(得分:1)

您正在创建新的ListBox并将其设置为ListBox1.Handle的值 - 但ListBox1.Handle会返回IntPrt类型 - 整数。

 Dim listBoxHandle As IntPtr

 listBoxHandle = ListBox1.Handle
 MessageBox.Show(listBoxHandle) // You'll see numbers.

答案 1 :(得分:0)

您必须使用IntPtr:

而不是ListBox
Dim i_Handle As IntPtr

i_Handle = ListBox1.Handle

答案 2 :(得分:-1)

句柄是一个IntPrt(一个句柄只是一个32位整数)。