.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发



(转)使用一个下拉框或文本框+列表框的方式实现类似IE地址栏自动完成的功能

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

转自"问专家:QA003240"

可以使用一个下拉框或文本框+列表框的方式实现。这样做的好处是下拉框的内容不一定是URL,可以是任意内容。下面是一个用下拉框实现的示例:
    ' *************Declarations
    Private Declare Function SendMessage Lib "user32" _
     Alias "SendMessageA" _
     (ByVal hwnd As Long, _
     ByVal wMsg As Long, _
     ByVal wParam As Long, _
     lParam As Any) _
     As Long
    
    Private Const WM_SETREDRAW As Long = &HB&
    Private Const CB_FINDSTRING As Long = &H14C&
    
    *************Here is the sub that will implement auto search
    
    Public Sub SearchCombo(InControl As Object)
    On Error GoTo trap
    
    Dim StrPos As Long
    Dim lPos As Long
    Dim SearchStr As String
    
     If TypeOf InControl Is ComboBox Then
     StrPos = InControl.SelStart
     SearchStr = Left$(InControl.Text, StrPos)
    
     lPos = SendMessage(InControl.hwnd, CB_FINDSTRING, 0, ByVal SearchStr)
    
     If lPos >= 0 Then
     InControl.Text = InControl.List(lPos)
     InControl.ListIndex = lPos
     End If
    
     With InControl
     .SelStart = StrPos
     .SelLength = Len(InControl.Text)
     End With
     End If
     Exit Sub
    trap:
     MsgBox Err.Description
    End Sub
    
    '**************Implement it like this************
    Private Sub cboParent_Change()
     Call SearchCombo(cboParent) '<--pass the combo box to the sub by name
    End Sub 
    
此问题由vbfan回答。


相关文章

相关软件