VB ActiveX ¨Ï¥Î¤èªk(¤G)

¦^­º­¶


¤ÀÃþ

¼ÐÃD

¤j·N

§@ªÌ

¤é´Á

TreeView ¦p¦ó¨ú±o Node ª«¥óªº¹ïÀ³°T®§ NodeClick Event ¦Ñ©Ç 1998/12/10
TreeView ¥Ñ¨Ï¥ÎªÌ¤â°Ê¥[¤J Node Nodes.Add ¤èªk ¦Ñ©Ç 1998/12/10
TreeView Âê¦í¬Y­Ó Node ¤£®e³\½s¿è BeforeLabelEdit ªº½s¿è¨Æ¥ó ¦Ñ©Ç 1998/5/23
MaskEdBox ®ø°£Åã¥Ü¦r¤¸ªº©³½u PromptChar ÄÝ©Ê ¦Ñ©Ç 1999/1/15
MsFlexEdit ¦Û°Ê±²°ÊÅã¥Ü·s¼W¸ê®Æ TopRow Äݩʪº§@¥Î ¦Ñ©Ç 1999/2/5
MsFlexEdit CellText ½s¿è¬É­±½d¨Ò TextBox °t FlexEdit ¦Ñ©Ç 1999/3/12
MsFlexEdit ²M°£¥ý«eªº Cell ³]©w¸ê®Æ ¡@ ¦Ñ©Ç 1999/4/16
MsFlexEdit ¦b Cell ¤¤´¡¤J¹Ï¤ù OleObject ª«¥óªº¨Ï¥Î ¦Ñ©Ç 1999/4/23
MsFlexEdit ¥Îµ{¦¡±²°Ê Cell ªºÅã¥Ü TopRow Äݩʪº¨Ï¥Î ¦Ñ©Ç 1999/5/16
MsFlexEdit ³Ì¾AÄæ¼e½d¨Ò ColWidth Äݩʪº¨Ï¥Î ¦Ñ©Ç 1999/6/3
MsFlexEdit ³Ì¾AÄæ°ª½d¨Ò RowHeight Äݩʪº¨Ï¥Î ¦Ñ©Ç 1999/6/5
MsFlexEdit MsFlexGrid »P DBGrid Sort ªº¤ñ¸û ¡@ ¦Ñ©Ç 1999/6/10
MCIControl ¦b PictureBox ¼½©ñ¼v¤ù¼v¹³ hWndDisplay Äݩʪº§@¥Î ¦Ñ©Ç 1999/2/6
CommonDialog ¦p¦ó°»´ú¹ï¸Ü²°ªº Cancel ¨Æ¥ó CancelError=True ¦Ñ©Ç 1999/3/5
CommonDialog ¦p¦ó°»´ú¨Ï¥ÎªÌ¦C¦L­¶¼Æ¿ï¾Ü Flags Äݩʪº¨Ï¥Î ¦Ñ©Ç 1999/4/1
SSTab ÁôÂí¶ÅÒ TabVisible Äݩʪº¨Ï¥Î ¦Ñ©Ç 1999/4/19
SSTab µ{¦¡°õ¦æ¤¤³]©w­¶ÅÒªº¼ÐÃD TabCaption Äݩʪº¨Ï¥Î ¦Ñ©Ç 1999/5/19
ToolBar µ{¦¡±±¨î«ö¤UToolbarªº«ö¶s Buttons Äݩʪº¨Ï¥Î ¦Ñ©Ç 1999/4/24
RichTextBox ¦C¦L RichTextBox ªº¤º®e SelPrint ¤èªkªº¨Ï¥Î ¦Ñ©Ç 1999/4/27
WinSock ¦p¦ó³sÄò SendData ¼Æµ§¸ê®Æ µ½¥Î SendComplete Event ¦Ñ©Ç 1999/5/13

¦p¦ó¨ú±o Node ª«¥óªº¹ïÀ³°T®§


tzigane ¼¶¼g©ó¤å³¹

Ä´¦p»¡·í·Æ¹« click tree¤¤ªº¬Y¤@­Ónode®É,¸Ónode©Ò¹ïÀ³¨ìªºª«¥ó,Ä´¦p»¡¬Y­Ó¦h´CÅéÀÉ«K·|¶}±Ò??

¦Ñ©Çµª¡G

  1. TreeView Node ª«¥ó¦³ Index¡BText¡BKey ¤T­ÓÄݩʥi¨ÑŪ¨ú¡G
  2. ¥¿½T¿ï¨ú Node ¤è¦¡¬O TreeView NodeClick ¨Æ¥ó¡G
    §A¦b Form ªº¤@¯ë«Å§i°Ï°µ
    Dim NodeKey As String
    Dim NodeText As String
    Dim NodeIndex As Integer
    µM«á¦b
    Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
    Dim TempNode As Node
        Set TempNode = Node
        NodeKey = TempNode.Key
        NodeText = TempNode.Text
        NodeIndex = TempNode.Index
    End Sub
    ´N¥i¥H«O¯d Node ªº¿ï¨ú­È¦Ó¦b Form ªº¨ä¥Lµ{§ÇùعB¥Î¡C

¦^¯Á¤Þ


¥Ñ¨Ï¥ÎªÌ¤â°Ê¥[¤J Node


'°õ¦æ¥»½d¨Ò½Ð©ó Form ¤W¥¬¸m TreeView1¡BText1¡BCommand1,2¡C
Option Explicit
Private Sub Command1_Click()
Dim TempNode As Node
    If TreeView1.Nodes.Count = 0 Then
        Set TempNode = TreeView1.Nodes.Add(, , , Text1.Text)
        Command2.Enabled = True
    Else
        Set TempNode = TreeView1.Nodes.Add(TreeView1.SelectedItem.Index, _
        , , Text1.Text)
    End If

    TempNode.EnsureVisible
    Set TreeView1.SelectedItem = TempNode
    Set TreeView1.DropHighlight = TempNode
End Sub
Private Sub Command2_Click()
Dim TempNode As Node
    Set TempNode = TreeView1.Nodes.Add(TreeView1.SelectedItem.Index _
            , tvwChild, , Text1.Text)
    TempNode.EnsureVisible
    Set TreeView1.SelectedItem = TempNode
    Set TreeView1.DropHighlight = TempNode
End Sub
Private Sub Form_Load()
    Command1.Caption = "¼W¥[¦P¼h¸`ÂI"
    Command2.Caption = "¼W¥[¤l¸`ÂI"

    Command2.Enabled = False
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
    Set TreeView1.DropHighlight = Node
End Sub

¦^¯Á¤Þ


®ø°£Åã¥Ü¦r¤¸ªº©³½u


±H¥óªÌ: »B»A³¾ Carlos Jang
·s»D¸s²Õ: tw.bbs.comp.language
¤é´Á: 1999¦~1¤ë14¤é 13:45
¥D¦®: [VB] ¦³Ãö MaskEdBox...

§Ú¦b¸ê®Æ®w¤¤ªº¤é´Á®æ¦¡¬O¦r¦ê«¬ºA§Î¦p "87-12-31"¡A²{¦b§Ú¥Î¤@­Ó MaskEdBox ¨Ó³sµ²¨ì³o­ÓÄæ¦ì¡A>§Ú·QÅý¨Ï¥ÎªÌ¤£¶·¿é¤J "-"¡A©Ò¥H mask = "##-##-##"¡A¦ý°õ¦æ®É¦³¸ê®ÆªºÄæ¦ì«oÅܦ¨ "__-__-__"¡A¥i¥H¸Ñ¨M³o­Ó°ÝÃD¶Ü¡H

¦Ñ©Çµª¡G

Private Sub Form_Load()
    MaskEdBox1.PromptChar = " "
End Sub

¦^¯Á¤Þ


¦Û°Ê±²°ÊÅã¥Ü·s¼W¸ê®Æ


±H¥óªÌ: Huang Wei Shin

msflexgrid ª«¥ó±N¸ê®Æ¤@µ§¤@µ§¼g¨ìgrid¤¤¡A¬O§_¥i¥H±N³Ì·sªº¸ê®ÆÅã¥Ü¦bµe­±¡A¦Ó¤£¬O­n    ¦Û¤v±²°Êscroll bar¥h¬Ý³Ì·sªº¸ê®Æ¡A¦Û°Ê·|²¾°Êscroll bar¡C

¦Ñ©Çµª¡G

    Private Sub Command1_Click()
        MSFlexGrid1.AddItem "Item:" & MSFlexGrid1.Rows
        MSFlexGrid1.TopRow = MSFlexGrid1.Rows - 1
    End Sub

¦^¯Á¤Þ


¦b PictureBox ¼½©ñ¼v¤ù¼v¹³


«°¥«Ây¤H ¼¶¼g©ó¤å³¹

MCI±±¨î¶µ­n«ç»òÅý¥¦¦bpicturebox¤W©ñ¥X¨Ó©O¡H

¦Ñ©Çµª

'´ú¸Õ¥»½d¨Ò½Ð©óªí³æ¥¬¸m MMControl1¡BCommand1¡BPicture1
Option Explicit
Private Sub Command1_Click()
    MMControl1.Command = "Play"
End Sub
Private Sub Form_Load()
    MMControl1.hWndDisplay = Picture1.hWnd
' Set properties needed by MCI to open.
    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.Shareable = False
    MMControl1.DeviceType = "avivideo"
    MMControl1.filename = "C:\temp\closeup.avi"
    '¶}±Ò MCI WaveAudio ¶gÃä³]³Æ¡C
    MMControl1.Command = "Open"
End Sub
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Close"
End Sub

¦^¯Á¤Þ


¦p¦ó°»´ú¹ï¸Ü²°ªº Cancel ¨Æ¥ó


¼s¹F·s¤@ ¼¶¼g©ó¤å³¹

§Ú¦bµ{¦¡¤¤¥Î CommonDialog ±±¨î¶µªº ShowOpen ¤èªk¶}±ÒÀɮסA§Ú¬O·Q..·í§Ú«ö¨ú®øªº¸Ü~~´Nµ²§ô¡A¥i¬O~~~¹ê»Ú¤W.«o·|©¹¤U¤@¦æÄ~Äò°õ¦æ~~½Ð°Ý³o¸Ó¦p¦ó¸Ñ¨M??

¦Ñ©Çµª¡G

¨â­Ó¿ìªk¡G

  1. §â CommonDialog.CancelError=True ¡A¨º«ö Cancel Áä´N·|¤Þµo¤@­Ó¿ù»~¨Æ¥ó¡A§A¦A¨Ì¦¹¿ù»~¨Æ¥ó¼gµ²§ôµ{¦¡¦p¡G
    Sub Command1_Click
    On Error GoTo CancelError
    CommonDialog1.ShowOpen
    '..................°õ¦æ¥¦¶µ±Ô­z
    Exit Sub

    CancelError:

    MsgBox Err.Description, vbOKOnly, "¿ù»~¥N½X¡G" & Err.Number
    End Sub
  2. ¦b CommonDialog.ShowOpen ¤§«e¡A¥ý CommonDialog.FileName=""
    ¦b  CommonDialog.ShowOpen ¤§«á¡A¦A¥Î If §PÂ_¬O§_ CommonDialog.FileName=""¡A¨Ó¨M©w¬O§_²×¤îµ{¦¡¡A¦p¡G
    Sub Command1_Click
    CommonDialog.FileName=""
    CommonDialog1.ShowOpen
    If CommonDialog.FileName="" Then
    Exit Sub
    Else
    '..................°õ¦æ¥¦¶µ±Ô­z
    End If
    End Sub

¦^¯Á¤Þ


CellText ½s¿è¬É­±½d¨Ò


MsFlexGrid «ç¼Ë¤]¥i¥HÅܪºÅý¨Ï¥ÎªÌ½s­×¸ê®Æ¡A¦Ó¤£¥u¬OÅã¥Ü¸ê®Æ¡A·íµM´N¬O¦bMsFlexGrid ªº Cell ¤Wµ¹¥¦©ñ¤@­Ó TextBox ¡A¦ÛµM¤]´N¥i¥H½s¿è Cell ¤º®eÅo¡C

'´ú¸Õ¥»½d¨Ò½Ð©ó Form ¤W¥¬¸m MsFlexGrid1¡AText1
Option Explicit

'°O¿ý­ì­×§ïªº Cell ®y¼Ð
Dim ColRec As Long, RowRec As Long

Private Sub Form_Load()
Dim DataItem As String
Dim I As Integer

    Set Text1.Font = MSFlexGrid1.Font
    '¥ý§â¤å¦r½s¿è²°Âð_¨Ó
    Text1.Visible = False

    '³]©w FlexGrid ¨Ï¥Î¤TÄæ
    MSFlexGrid1.Cols = 3

    '¥[¤­¤Qµ§°O¿ý
    For I = 1 To 50
        MSFlexGrid1.AddItem "«~¶µ" & I & Chr(9) & "¦WºÙ" & I & Chr(9) _
                & "³W®æ" & I
    Next
End Sub

Private Sub MSFlexGrid1_EnterCell()
    '²¾°Ê¨Ã½Õ¾ã TextBox ¤j¤p¡A¨Ï¯à©ñ¤J FlexGrid ªº Cell ¤º¡A
    '¨Ã§â Cell ¸ê®Æ©ñ¤J TextBox ¤º¡C
    With MSFlexGrid1
        ColRec = .Col
        RowRec = .Row
        Text1.Move .Left + .CellLeft, .Top + .CellTop, _
                .CellWidth, .CellHeight
        Text1.Text = .Text
    End With

    '¨Ï TextBox ¬°¥i¨£¡A¨Ã¨ú±oµJÂI¡C
    With Text1
        .Visible = True
        .SetFocus
    End With
End Sub

Private Sub MSFlexGrid1_LeaveCell()
    'Â÷¶}¬Y Cell ¶i¤J¥t¤@ Cell ¡A«h¶i¦æ Cell ¸ê®Æ§ó·s°Æµ{¦¡¡C
    CellDataChange
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        '¦b TextBox ùØ«ö Enter Áä ¡A¤]¶i¦æ Cell ¸ê®Æ§ó·s°Æµ{¦¡¡C
        CellDataChange
    End If
End Sub

'¸ê®Æ§ó·s°Æµ{¦¡
Private Sub CellDataChange()
    MSFlexGrid1.TextMatrix(RowRec, ColRec) = Text1.Text
    Text1.Visible = False
    MSFlexGrid1.SetFocus
End Sub

¦^¯Á¤Þ


¦p¦ó°»´ú¨Ï¥ÎªÌ¦C¦L­¶¼Æ¿ï¾Ü


±H¥óªÌ: tien

¥ÎCommondialog¤¤ªºshowprint¡A¦p¦ó°»´ú¨Ï¥ÎªÌ¦ó®É¿ïªº¬O¡u¦C¦L¥þ³¡¡v¡B¡u¦C¦L¿ï¨ú½d³ò¡v¡H

¦Ñ©Çµª¡G

Private Sub Command1_Click()
    CommonDialog1.ShowPrinter

    If CommonDialog1.Flags And cdlPDSelection Then
        Debug.Print "¨Ï¥ÎªÌ¿ï¾Ü¦C¦L¿ï¨ú½d³ò"
    Else
        If CommonDialog1.Flags And cdlPDPageNums Then
            Debug.Print "¨Ï¥ÎªÌ¿ï¾Ü¦C¦L­¶¼Æ"
        Else
            Debug.Print "¨Ï¥ÎªÌ¿ï¾Ü¥þ³¡¦C¦L"
        End If
    End If
End Sub

¦^¯Á¤Þ


²M°£¥ý«eªº Cell ³]©w¸ê®Æ


laigs ¼¶¼g©ó¤å³¹

½Ð°Ý¦bMSFlexGrid¡A¦pªG¤w¸g¶}¤@­ÓÀÉ®×¶i¨Ó¡A­Y·Q¥t¶}¤@­ÓÀÉ®×¶i¨Ó¡A½Ð°Ý¦p¦ó²M°£­ì¦³MSFlexGrid¤¤ªº¸ê®Æ¡A½Ð°ª¤â«üÂI¡I«üÂI¡IÁÂÁ¡I¡I

¦Ñ©Çµª¡G

­n¬Ý§A·íªì¬O«ç»ò¥[¸ê®Æªº¡C

  1. ¥Î AddItem ¥[¸ê®Æªº¥Î RemoveItem ²¾±¼¡C
  2. ¥Î Rows=Number ,Cols=Number ¥[¸ê®Æªº¥Î Rows=0 ,Cols=0 ²¾¸ê®Æ¡C
  3. ¥H³]©w DataSource ÄݩʡA¥Î Data ±±¨î¶µ´£¨Ñ¸ê®Æªº¡AData.Recordset §ïÅÜ MFlexGrid ·|¸òµÛ°t¦X§ïÅÜ¡C

¦^¯Á¤Þ


ÁôÂí¶ÅÒ


(Å]¬P) ªº¤å³¹¤¤´£¨ì:

¦bVB¤¤¦ü¥G¨S¦³ Page Control ¤¸¥ó¡A¦Ó SSTab ¤¸¥ó¤S¨S¦³ TabVisible ÄݩʡC

¦Ñ©Çµª¡G

SSTab ¦³ TabVisible ÄݩʡA§A¥i¥H¥Î¦b Tab(0),(1),(2) ¤À§O©ñ Command1,2,3 ¡AµM
«á°õ¦æ¤U¦C Code ¨Ó¤@¤@Åã¥Ü¨C¤@­¶ Tab¡G
Private Sub Command1_Click()
    SSTab1.TabVisible(0) = False
    SSTab1.TabVisible(1) = True
    SSTab1.TabVisible(2) = False
    SSTab1.Tab = 1
End Sub
Private Sub Command2_Click()
    SSTab1.TabVisible(0) = False
    SSTab1.TabVisible(1) = False
    SSTab1.TabVisible(2) = True
    SSTab1.Tab = 2
End Sub
Private Sub Command3_Click()
    SSTab1.TabVisible(0) = True
    SSTab1.TabVisible(1) = False
    SSTab1.TabVisible(2) = False
    SSTab1.Tab = 0
End Sub
Private Sub Form_Load()
    SSTab1.TabVisible(0) = True
    SSTab1.TabVisible(1) = False
    SSTab1.TabVisible(2) = False
End Sub

¦^¯Á¤Þ


¦b Cell ¤¤´¡¤J¹Ï¤ù


»P¹qÁçÄñºøªº¨k«Ä ¼¶¼g©ó¤å³¹

¤£ª¾¹DRICHTEXTBOX¯à¤£¯à¦b¤å¥ó½s¿è¤¤§t¹Ï¤ù¡A¦pªG¥i¥H«ç»ò¼Ë°µªü?

¦Ñ©Çµª¡G

¥u¥i¥H¥Î OLE ¤è¦¡´¡¤J¹Ï¤ù¡A½s¿è¤´¥Ñ­ì²£¥Íµ{¦¡½s¿è¤§¡C½d¨Ò¦p¤U¡G
RichTextBox1.OLEObjects.Add Index,Key,"BMPPathandName","ProgID"
or
RichTextBox1.OLEObjects.Add ,,"BMPPathandName"

¦^¯Á¤Þ


µ{¦¡±±¨î«ö¤UToolbarªº«ö¶s


©ÜµÛ¥øÃZ¥Öªºª°¯W ¼¶¼g©ó¤å³¹

¦pªG§Ú­n¥Îµ{¦¡±±¨î«ö¤UToolbar³oª«¥ó¤Wªº«ö¶s¡A¸Ó¦p¦ó¼g£z?¤ñ¦p»¡¡A«ö¤UÁä½L¤WªºF2´Nµ¥©ó«ö¤Utoolbar¤Wªº²Ä¤@­Ó¶s , ­n¦p¦ó¼g¤~¦æ°Ç?

¦Ñ©Çµª¡G

Option Explicit

Dim IconState As Byte

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF2 Then
        'Button.Value ¥u±µ¨ü 0,1 ¤G¼Æ¡A¬G¤£¥i¥Î Boolean «¬ºA³]©w¨ä­È¡A
        '¦]¬° True ­È·|³Q´«ºâ¦¨ -1 ¦Ó¾É­P Err.Eraise
        IconState = Abs(IconState - 1)
        Toolbar1.Buttons(1).Value = IconState
    End If
End Sub

¦^¯Á¤Þ


¦C¦L RichTextBox ªº¤º®e


»P¹qÁçÄñºøªº¨k«Ä ¼¶¼g©ó¤å³¹

½Ð°Ý­n¦p¦ó¦C¦LRICH TEXT BOXªº¤º®e¡A§Úªº¤º®e¤¤ÁÙ§t¦³¹Ï¤ù¸ò¤å³¹!!

¦Ñ©Çµª¡G

±z¥i¥H¨Ï¥Î¤U¦Cªºµ{¦¡½X¶Ç°e¨ì Printer ª«¥ó¡G
RichTextBox1.SelPrint(Printer.hDC)

¦^¯Á¤Þ


¦p¦ó³sÄò SendData ¼Æµ§¸ê®Æ


¡i (­Û­Û) ªº¤j§@¤¤´£¨ì: ¡j

½Ð°Ý¤@¤U...§Ú¦bvb¤¤¨Ï¥ÎwinsockªºSendData¨Ó¶Ç°e¸ê®Æ...¦ý¦pªG§Ú³sÄò¨Ï¥ÎSendData¨â¦¸...¨Ò: winsock.SendData a,winsock.SendData b ¡A±`¦b a ¨S¶Ç§¹´N³Qµ²§ô¦Ó¥h¶Ç b¡A­n«ç»ò¸Ñ¨M¡H

¥|¶¡ ¼¶¼g©ó¤å³¹

DoEvents   //¦b¨â­ÓSendData¤¤¥[¤J¦¹¦æ§Y¥i...¥Øªº¬OÅýµ{¦¡¼È°±¤@¤U¡C

¦Ñ©Çµª¡G

¤£¦n·N«ä¡A§Úı±o DoEvents ¤è¦¡·|³y¦¨«Ü¤jªºµ{¦¡¦M¾÷¡A¦]¬°¦pªG°eªº¸ê®Æ«Ü¤j¡A©Î¬O­è¥©ºô¸ô¶Ç°e¤£¬O«Ü¶¶¡A¯Ó®É«Ü¤[ªº¸Ü¡A§Aªºµ{¦¡·|ÅܪºµLªk¹w´ú¡A¸Õ¸Õ¤U­±³o¬qWork ¤£ Work¡G

'´ú¸Õ¥»½d¨Ò½Ð©óªí³æ¥¬¸m Command1¡BWinsock1¡BTimer1
Option Explicit

'­n¤À§å¶Ç°eªº°}¦C¸ê®Æ
Dim PushArray() As String
'±±¨î¶Ç¤U¤@µ§ªººX¼Ð
Dim Sending As Boolean

Private Sub Command1_Click()
    ReDim PushArray(2)
    PushArray(0) = "§Aªº²Ä¤@­Ó¶Ç°e¦ê"
    PushArray(1) = "§Aªº²Ä¤G­Ó¶Ç°e¦ê"
    PushArray(2) = "§Aªº²Ä¤T­Ó¶Ç°e¦ê"

    Timer1.Enabled = True
End Sub

Private Sub Form_Load()
    Timer1.Interval = 30
    Timer1.Enabled = False
End Sub

'­n¥Î Timer ¥Øªº¦b¤£°±°»´ú WinSock SendComplete ¤F¨S¦³
Private Sub Timer1_Timer()
Static SendIndex As Long
    '¥u¦³ SendComplete ¤§«á¤~¶Ç¤U¤@µ§
    If Not Sending Then
        'Sending ³]¬° True ªí¥Ü¶}©l¶Ç¸ê®Æ
        Sending = True
        Winsock1.SendData PushArray(SendIndex)
        If SendIndex >= UBound(PushArray) Then
            SendIndex = 0
            '¥þ³¡¶Ç§¹Ãö³¬ Timer
            Timer1.Enabled = False
        Else
            SendIndex = SendIndex + 1
        End If
    End If
End Sub

Private Sub Winsock1_SendComplete()
    'Sending ³]¬° False ªí¥Ü¤@µ§¸ê®Æ¶Ç§¹
    Sending = False
End Sub

¦^¯Á¤Þ


¥Îµ{¦¡±²°Ê Cell ªºÅã¥Ü


Option Explicit
Dim All As Long
Private Sub Command1_Click()
Dim I As Long
    Data1.Recordset.MoveLast
    Data1.Recordset.MoveFirst

    All = Data1.Recordset.RecordCount
    Timer1.Enabled = True
End Sub
Private Sub Form_Load()
    Timer1.Interval = 1
    Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Static I As Long
    MSFlexGrid1.TopRow = I + 1

    If I < All - 1 Then
        I = Data1.Recordset.AbsolutePosition + 1
        Data1.Recordset.MoveNext
    Else
        I = 0
        Timer1.Enabled = False
    End If
End Sub

¦^¯Á¤Þ


µ{¦¡°õ¦æ¤¤³]©w­¶ÅÒªº¼ÐÃD


¦ò¤ª¡G¤£¥i»¡¡I ¼¶¼g©ó¤å³¹

VB¤¤¡ASStab­¶ÅÒªºcaption¦bµ{¦¡°õ¦æ¤¤­n«ç»ò³]©w¡H¦p¡Aform1¡Asstab1¡A¤W­±¦³¤T­¶¡K­n§â²Ä¤T­Ó­¶ÅÒªºcaption³]¦¨¡§CCC¡¨¡K

¦Ñ©Çµª¡G

SSTab1.TabCaption(2) = "CCC"

¦^¯Á¤Þ


Âê¦í¬Y­Ó Node ¤£®e³\½s¿è


­ü! ¼¶¼g©ó¤å³¹

½Ð°Ý,­n¦p¦ó³]©w¤~¯à§@¦¨°ßŪªº©O?¥L¨S¦³LOCKED=TRUEªºÄݩʭȡC

¦Ñ©Çµª¡G

¥²¶·¥Î¥t¥~Åܼƥh°O¿ý¥¦ªº Locked ¡A¨Ã¥B¦b¶}©l½s¿è¨Æ¥ó¤¤¨ú®ø¨ä½s¿è¡C
Option Explicit

'°O¿ý¥Ø«e§@¥Î¤¤¸`ÂIªºÅܼÆ
Dim MyNode As Node

Private Sub Form_Load()
    '³]©w Treeview ±±¨î¶µÄݩʡC
    TreeView1.LineStyle = tvwRootLines  ' Linestyle 1
    '·s¼W Node ª«¥ó¡C
    Dim nodX As Node    '«Å§i Node ÅܼơC
    '²Ä¤@­Ó¸`ÂI±a¦³¤å¦r 'Root' ¡C
    Set nodX = TreeView1.Nodes.Add(, , "r", "Root")
    '¤U¤@­Ó¸`ÂI¬O¸`ÂI 1 ("Root") ªº¤l¸`ÂI¡C
    Set nodX = TreeView1.Nodes.Add("r", tvwChild, "child1", "Child")
End Sub

Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
    '¦pªG¥Ø«e§@¥Î¤¤¸`ÂIªºKey = "child1"¡A«h¤£¤¹³\½s¿è¡C
    If MyNode.Key = "child1" Then
        Cancel = -1
    End If
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
    '¥Î MyNode °Ñ·Ó¥Ø«e§@¥Î¤¤ªº¸`ÂI
    Set MyNode = Node
End Sub

¦^¯Á¤Þ


³Ì¾AÄæ¼e½d¨Ò


'¥»½d¨Ò¯àÅý§A¦b MsFlexGrid ªº ColCaption ¤W«ö¨â¤U¡A¦Û°Ê½Õ¾ã¾ãÄæ¤j¤p¡C
Option Explicit
Private Sub MSFlexGrid1_DblClick()
    '¥u¦³¦b Col Caption ¤W«ö¨â¤U¡A¤~·|Åý
    'MSFlexGrid1.RowSel = MSFlexGrid1.Rows - 1
    If MSFlexGrid1.RowSel = MSFlexGrid1.Rows - 1 Then
        'Call ¦Û°Ê½Õ¾ãÄæ¼eªº¦Û­q¥\¯à¨ç¼Æ
        FixColWidth Me, MSFlexGrid1, MSFlexGrid1.ColSel
    End If
End Sub

'¦Û°Ê½Õ¾ãÄæ¼eªº¦Û­q¥\¯à¨ç¼Æ
'°Ñ¼Æ¡G
'MyForm:MsFlexGrid ©Ò¦b Form ªº°Ñ·Ó
'Fg:­n½Õ¾ãÄæ¼eª«¥óªº°Ñ·Ó
'ColNo:½Õ¾ãÄæ¦ìªº Index
Private Sub FixColWidth(MyForm As Form, FG As MSFlexGrid, ByVal ColNo As
Integer)
Dim MeFont As StdFont
Dim ColW As Single, I As Long
    '¥ý¦s¤U MyForm ªº¦r«¬³]©w¥H«K°Ï¬qµ²§ô«á¦^´_­ì³]©w
    Set MeFont = MyForm.Font
    '¥HÂI¿ïÄæ¦ì¬°¨Ï¥Î¤¤Äæ¦ì
    FG.Col = ColNo

    '¤ñ¹ï©Ò¦³ Row ¤¤¨º¤@µ§¸ê®Æ³Ìªø
    For I = 0 To FG.Rows - 1
        FG.Row = I
        MyForm.Font.Name = FG.CellFontName
        MyForm.Font.Bold = FG.CellFontBold
        MyForm.Font.Italic = FG.CellFontItalic
        MyForm.Font.Size = FG.CellFontSize

        If ColW < MyForm.TextWidth(FG.Text) Then
            ColW = MyForm.TextWidth(FG.Text)
        End If
    Next

    '³Ìªø­È¦A¥[ÂIÃä¬É­È°µ½Õ¾ãªº¼e«×
    FG.ColWidth(ColNo) = ColW + ScaleX(6, vbPixels, MyForm.ScaleMode)
    '¦^´_ MyForm ­ì¦r«¬³]©w
    Set MyForm.Font = MeFont
End Sub

¦^¯Á¤Þ


³Ì¾AÄæ°ª½d¨Ò


tom ¼¶¼g©ó¤å³¹

¦]¬°­^¤å¹ê¦b¤Óªø¤F¡A©Ò¥H§Ú·Q§â¥¦¼g¦¨¨â¦æ¡A¥i¥H¶Ü¡H

¦Ñ©Çµª¡G

  1. MsFlexGrid.WordWrap=True ´N¥i¥H¦Û°Ê§é¦æ¡A¤£¶·§A§â¥¦¼g¦¨¨â¦æ¡C
  2. MsFlexGrid ªº RowHeight °ª«×¤£·|¦Û°Ê©ñ¤j¡A©Ò¥H¥²¶·¦Û¤v¥Îµ{¦¡©Ô¤j RowHeight ªº¶¡¶Z¡A¤~¯à¬Ý¨ì§¹¾ãÅã¥Ü¡A½d¨Ò¦p¤U¡G
  3. '½d¨Ò¨Ï¥Î¤è¦¡¡G±N Grid Äæ¼e½Õ¦Ü©Ò»Ý¤j¤p¡A«ö¤U­«±Æ¶s¡A§Y¥i¨Ì CellText
    'ªø«×­«·s³]©w¨C¦C°ª«×
    '¨Ï¥Î¥»½d¨Ò¡A½Ð©óªí³æ¥¬¸m MsFlexGrid1,Command1
    Option Explicit

    'MsFlexGrid ªº CellText ©M Cell Ãä¬Éªº¶¡¹j¼e«×
    Private Const BORDERWIDTH As Integer = 6

    Private Sub Command1_Click()
    '°O¿ý­ì Cell ªº¦ì¸m
    Dim OldCol As Long, OldRow As Long
    '°O¿ý­ì Form ªº Font ³]©w
    Dim OldFont As StdFont
    '±µ¦¬­«±Æ¦r¦êªºÅܼÆ
    Dim AcceptString As String
    '³]©w MsFlexGrid.RowHeight ªº¹BºâÅܼÆ
    Dim LineHeight As Single
    '³æ­Ó Cell ±Àºâªº°ª«×
    Dim WordHeight As Single
    '°j°é­p¼Æ¾¹
    Dim I As Long, J As Long

        '°O¿ý Form ªº¦r«¬³]©w
        Set OldFont = Me.Font
        '°O¿ý­ì Grid ªº¨Ï¥Î Cell ¦ì¸m
        OldCol = MSFlexGrid1.Col
        OldRow = MSFlexGrid1.Row

        '³v¦C­pºâ Grid ªº¨C¦C¦C°ª
        For I = 0 To MSFlexGrid1.Rows - 1
            'ÁÙ­ì«e¦¸¦C°ª³]©w
            LineHeight = 0
            MSFlexGrid1.Row = I

            '³vÄæÀˬd¨C­Ó Cell §¹¾ãÅã¥Ü©Ò»Ý°ª«×
            For J = 0 To MSFlexGrid1.Cols - 1
                MSFlexGrid1.Col = J

                '¨Ì¦U Cell ¦r«¬³]©w­pºâ¦C°ª
                Me.Font.Name = MSFlexGrid1.CellFontName
                Me.Font.Bold = MSFlexGrid1.CellFontBold
                Me.Font.Italic = MSFlexGrid1.CellFontItalic
                Me.Font.Size = MSFlexGrid1.CellFontSize
                '¥Î WrapCell ¦Û­q¨ç¼Æ­«·s¨Ì ColWidth §â CellText ±Æ¦¨¼Æ¦æ¡C
                AcceptString = WrapText(MSFlexGrid1.Text,
    MSFlexGrid1.ColWidth(J))
                '­pºâ§¹¥þÅã¥Ü­«±Æ«áªº CellText ©Ò»Ý°ª«×
                WordHeight = Me.TextHeight(AcceptString)

                '­Y Grid ¦C°ª¤p©ó CellText ©Ò¶·°ª«×«h©ñ¤j¤§
                If LineHeight < WordHeight Then
                    LineHeight = WordHeight
                End If
            Next
            '¤W¤U¦U¥[¨â­Ó¹Ï¯À°µÃä¬É
            MSFlexGrid1.RowHeight(I) = LineHeight + ScaleY(BORDERWIDTH,
    vbPixels, Me.ScaleMode)
        Next

        'ÁÙ­ì¦U¶µ³]©w
        Set Me.Font = OldFont
        MSFlexGrid1.Col = OldCol
        MSFlexGrid1.Row = OldRow
    End Sub

    Private Sub Form_Load()
    Dim CellString As String

        Command1.Caption = "­«±Æ"

        '¨Ï¥ÎªÌ¥i½ÕÄæ¦ì¼e«×
        MSFlexGrid1.AllowUserResizing = flexResizeColumns
        '¶W¹L CellWidth ¡ACellText ¥i¦Û°Ê§é¦æ¡C
        MSFlexGrid1.WordWrap = True
        '¶ë¤J¤@¨Çªø¦r¦ê¸ê®Æ
        MSFlexGrid1.Cols = 4
        MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1

        CellString = "1" & Chr(9) & "³o¼Ëªº°ÝÃD¤@¶}©l´N®e©ö°¾»á¡G" & Chr(9)
        CellString = CellString + "²Ä¤@¡A¤°»ò¥s¥Á¡A§A¦n¹³»{¬°¥j¤¤°ê´N¥u¦³¨âºØ¤H¡A¤@ºØ¥s©x¡A¤@ºØ¥s¥Á¡C" & Chr(9)
        CellString = CellString + "¨Æ¹ê¤W´Nºâ¥j¤¤°ê¨ººØ¤£¶}¤ÆªºªÀ·|¡A¥Áªº²Õ¦¨¤]¤Q¤À½ÆÂø¡C"

        MSFlexGrid1.AddItem CellString

        CellString = ""
        CellString = "2" & Chr(9) & "°Ó¤Hºâ¤£ºâ¥Á" & Chr(9)
        CellString = CellString + "¤â¤uÃÀªÌºâ¤£ºâ¥Á" & Chr(9)
        CellString = CellString + "¤p¦a¥Dºâ¤£ºâ¥Á"

        MSFlexGrid1.AddItem CellString

        CellString = ""
        CellString = "3" & Chr(9) & "´Nºâ¦P¬O¦Û¯Ñ¹A" & Chr(9)
        CellString = CellString + "¾D¯î¦a°Ïªº¦Û¯Ñ¹A¸òÂצ¬¦a°Ïªº¦Û¯Ñ¹A¶D¨D¤£¤@¼Ë" & Chr(9)
        CellString = CellString + "¤g¦a­Ý¨ÖÄY­«©M¹A¦a¦Û¦³¦a°Ï¦Û¯Ñ¹A¶D¨D¤]¤£¤@¼Ë"

        MSFlexGrid1.AddItem CellString

    End Sub

    '¨Ì«ü©w¼e«×±N¦r¦ê­«±Æ¦¨¼Æ¦æªº¦Û­q¨ç¼Æ
    'SendString:­«±Æ¦r¦ê
    'CWidth:­«±Æ¼e«×
    '¶Ç¦^­È:¥[¤J¤À¦æ²Å¸¹ªº¦r¦ê
    Private Function WrapText(ByVal SendString As String, ByVal CWidth As
    Single) As String
    Dim RetString As String
    Dim LineString As String
    Dim SWord As String * 1
    Dim I As Long
        For I = 1 To Len(SendString)
            '³v¦r¨ú¥X­«±Æ¦r¦ê
            SWord = Mid(SendString, I, 1)
            '¥[¨ì³æ¦æ¦r¦êùØ
            LineString = LineString & SWord

            '¦pªG¥[¤J¦¹ SWord ³æ¦r«á¡A¶W¹L­«±Æ¼e«×¡C
            If Me.TextWidth(LineString) > (CWidth - ScaleX(BORDERWIDTH, vbPixels, Me.ScaleMode)) Then
                '§â³æ¦æ¦r¦ê¥[¤J¶Ç¦^¦r¦ê¡A¨Ã©óµ²§À¥[¤W¤À¦æÂk¦ì¦r¤¸
                RetString = RetString & LineString & vbCrLf
                '²M°£³æ¦æ¦r¦ê
                LineString = ""
                '§â¶W¹Lªº³æ¦r¥[¤J¤U¤@­Ó³æ¦æ¦r¦ê
                LineString = LineString & SWord
            End If
        Next

        '§â³Ì«á¤@¦æ¥[¤J¶Ç¦^¦r¦ê
        RetString = RetString & LineString

        WrapText = RetString
    End Function

¦^¯Á¤Þ


MsFlexGrid »P DBGrid Sort ªº¤ñ¸û


  1. MsFlexGrid ±±¥óªºÄæ¦ì±Æ§Ç¡A¬Oª½¥Ñ±±¥ó¥»¨­ª½ÄÝÄݩʾާ@¡A»yªk¬O¡G
    MsFlexGrid1.Sort=ColIndex (¾ã¼Æ­È)
  2. DBGrid «h±±¥ó¥»¨­¨S¦³ Sort ªºÄݩʩΤèªk¡A¥u¯à¥Ñ Data Control ´£¨Ñ¦³±Æ§Çªº°O¿ýµ¹¥¦¡C

¦^¯Á¤Þ


¦^­º­¶

1