如题,
如何编程解决,通过Combo编辑Listview中的东西?
或是有类似的控件,哪里下载?谢谢~~

解决方案 »

  1.   

    可用api函数setparent实现:
    setparent
    指定一个窗口的新父(在vb里使用:利用这个函数,vb可以多种形式支持子窗口。例如,可将控件从一个容器移至窗体中的另一个。用这个函数在窗体间移动控件是相当冒险的,但却不失为一个有效的办法。如真的这样做,请在关闭任何一个窗体之前,注意用SetParent将控件的父设回原来的那个)实例:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
    Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
    Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
    Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
    Const GW_HWNDNEXT = 2
    Dim mWnd As Long
    Function InstanceToWnd(ByVal target_pid As Long) As Long
        Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
        'Find the first window
        test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
        Do While test_hwnd <> 0
            'Check if the window isn't a child
            If GetParent(test_hwnd) = 0 Then
                'Get the window's thread
                test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
                If test_pid = target_pid Then
                    InstanceToWnd = test_hwnd
                    Exit Do
                End If
            End If
            'retrieve the next window
            test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
        Loop
    End Function
    Private Sub Form_Load()
        Dim Pid As Long
        'Lock the window update
        LockWindowUpdate GetDesktopWindow
        'Execute notepad.Exe
        Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
        If Pid = 0 Then MsgBox "Error starting the app"
        'retrieve the handle of the window
        mWnd = InstanceToWnd(Pid)
        'Set the notepad's parent
        SetParent mWnd, Me.hwnd
        'Put the focus on notepad
        Putfocus mWnd
        'Unlock windowupdate
        LockWindowUpdate False
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'Unload notepad
        DestroyWindow mWnd
        'End this program
        TerminateProcess GetCurrentProcess, 0
    End Sub
      

  2.   

    不过,编辑Listview中的东西,好象用不着这么麻烦吧,直接改就是了。最好把你的问题说的详细些,比如你要改什么东西,图标,文字?
      

  3.   

    when combobox changed, and addition condition reach, then
     let listview.value = new value???
      

  4.   

    啊,对不起,没看明白啊,
    这程序能把Listview和Combo关联起来?我也试着定位过Combo,可是问题很多,比如说大小控制问题,滚动条定位问题,焦点控制问题等,头都大了~~
      

  5.   

    就是比如人员资料,其中的性别是要选择,可以把Combo放到一边选择,或是用右键菜单选择,但是我记得Delphi的dbGrid可以用下拉菜单的,我感觉VB也应该可以,做了一些实验,失败了,查了一些资料好像很少
      

  6.   

    为什么我的listview没有了checkbox??? 以前都找的到现在没了。。
      

  7.   

    listview中有选项。可以设置它的属性,好好找找吧。。
      

  8.   

    to  pigsanddogs
        你的控件版本低,可能是5.0的,换6.0的试试...
      

  9.   

    打一个sp5的包就恢复了,要么就重装一下vb
      

  10.   

    上来的有些跑题了。
    用rainstormmaster(rainstormmaster) 的方法试试,