如何在VB.NET 2005中获取ListBox控件的句柄?
我正在使用
Dim i_Handle As ListBox
i_Handle = ListBox1.Handle
但这不起作用
答案 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:
而不是ListBoxDim i_Handle As IntPtr
i_Handle = ListBox1.Handle
答案 2 :(得分:-1)
句柄是一个IntPrt(一个句柄只是一个32位整数)。