ҡդӶ ʵŧ 纺촨շ٨絴͵ ᷹ФѺ

͵Դҷҧ Inbox Ѻ

˹ѡ
-
VB 6/VB.Net
ASP/ASP.Net
Ѻ¤
¹ҹ Flash Movie
ռͺش  
 RSS Feeds
 ǹŴ RSS Reader ...   Download  RSS Reader

Forum - www.g2gnet.com
Webmaster - www.g2gnet.com
Visitors - Session views
 5 6 1 6 1 6 6

7 ѹҤ ..2549
121 Users On-Line.
Visitors - Page views
 8 9 7 3 9 0 9
1 Ҿѹ ..2551

Google   
g2gnet.com
Ҵѡ:  

ҧԴ (MS Flex Grid) ... VB 6.0

Category »  VB 6/VB.Net
: Webmaster 9/11/2549 14:11:00
(ҹ : 48577) 

Ѻҹ ѹ繧ҹµ¤ ͧѹͧͧ ෤š ෤ ѡҡ Ѻͧͧ (оǡ ... ѧѺ ѧա) Ѻͧ ѹͧͧ "Թҡ" ҧŻ ͺὧ () ҡººѺ 礧ҧ仨ҡѺ "ͧͧʵ Ż" ûҳФѺ ... ͧ

... ѹ礧еͧ˵ ռ ѹ ͧҴٵҧѹ

ҧԴ (Grid) Control Ӥѭա˹觷繵ͧҹ Visual Basic ҧ ͹ʴŢ ҡҧҹ֡͡ ֧ͧ֡Ҿͧ Excel 䧤Ѻ ѹ (Row) ѡ (Column) ǹ˭ Grid ж١ͧͧҹ ѭҢͧ Grid
(Ѻǡ ADO Grid Bound Control Ӿǡ "" ͡ô֧ʴ "ҡ" ͡äǺ)
"ѹʴҧ" 觨ö䢢ŵҧ Cell ... Ф "ѭ"
    "ѭ ѭ" ... ѹѺá "Թҡ" ѹ͹
  1. öҵ˹觢ͧ Cell ѹ ѡ
  2. ö͹ Cell ҧ 鹾 ...

Ũҡ÷ͺ

' Code 鷴ͺ
Private Sub fg_Click()
    MsgBox "Ƿ " & fg.Row & " " & "ѡ " & fg.Col & vbCrLf & "Left=" & fg.CellLeft & vbCrLf & "Top=" & fg.CellTop
End Sub

ͤѺ ... 觷ͧҹ觹֧֡ͧͧ "سѵ - Properties" ШӵǢͧǡ Control ҹ䧤Ѻ ѹ繵ҧԴ 觵ͧաҧԧͧͧ Cell ǹҹ䧤Ѻͧ ѧҨ֧价͹ ҵ˹觢ͧ Cell ...
㹢зµ͡Ẻ Ҥ ѹѧ֡͡͡Ѻ § (ͧ) ҡ ҳ ѹ¾ͨͧҧҧҧǤѺͧ Ǥ ͹ͧ Cell ѹ·֧֡ͧ "Method - Ըա" ҧ˹觢 蹤 "Move" Ѻм

Ҷ֧ش ... ͧ "Թҡ" ѹա ҡ͡˹ Cell ҵͧǹ ͧ͹˹觢ͧ TextBox 任ԴѺ ˹觹 ͻ͹ ͻ͹º (Դ˵ءó Event - Change) еͧѧѺѹ¹ŧҷ Cell ҵͧù ... ѹ͡ ԴҨ ???

ӵͺ: öҵҧŧ Cell ǹ ¤

    fg.TextMatrix(Ƿͧ, ѡͧ) = "ͤ"
    fg.Text = "ͤ"


Ũҡ÷ӧҹͧ

ѧ鹡ŧͷӵԹҡ

 

ѹѺá͡ Component ҡ͹价 Project --> Components...


͡ Components


Microsoft FlexGrid Control 6.0


    仡ӡҡ Control ͡ 2 Сͺ
  1. MS FlexGrid Control
  2. TextBox


    Properties سѵԷӤѭѺ Control е մѧ (Design-Time)
      MS FlexGrid
    1. Name: fg
    2. Fixed Rows: 1
    3. Fixed Cols: 0
    4. Rows: 2
    5. Cols: 4

      TextBox
    1. Name: Text1
    2. Text: Text1
    3. Visible: False ͧԴʴš͹Ѻ

ͺ

ҡҾҹش صҼͧ÷䢤ҵҧ ѡ 3 ҹ (Ҥ) ǹѡǡѹѺ ...

鹡кǹ

Event/Driven ˵ءóФѺ á˹˹觢ͧ Cell ҵͧè¹ŧ

Private Sub fg_EnterCell() ' ԨóҨҡ˵ءó (Event) 㹡 Focus ç˹ Cell
Select Case fg.Col ' ͡ Column ͧ
    Case 0, 1, 2: ' ͹ѡ 0, 1 2
        Text1.Visible = False ' ֧ͧԴͧ Text1

    Case 3: '  ١ͧ Cell ѧ Focus ѡ 3 鹡кǹ÷ӧҹ
        Text1.Visible = True ' Դ Text1 ͧ
        Text1.Text = fg.Text '  Cell ж١觵 Text1 ͷӡ䢵

        ' 鹵͹͡͹˹觢ͧ Text1 价Ѻ躹˹觢ͧ Cell (ѡ˹) ҵͧ
        ' ͹ fg.Move ˹觷ҧ, ˹觺, ҧͧ, ٧ͧ
        Text1.Move fg.CellLeft, fg.CellTop, fg.CellWidth, fg.CellHeight

        '  Text1 ͹价Ѻ˹ Cell ҵͧ Focus 价 Text1 ͷö䢢ŧ TextBox
        Text1.SetFocus
End Select
End Sub

Private Sub Form_Load() ' ҷͺѡ
Dim sRow As Byte, i As Byte
Call SetupGrid ' 觵駤 FlexGrid
Text1.Text = "" '  TextBox
' 繢صԢͷͺѺ
For i = 0 To 4
    With fg
        sRow = .Rows - 1 ' ͧҡǷ˹ (Rows) 2 Ǻش 0 Header ǹ鹷ͧ令Ƿ 1 (1 = 2 - 1)
        .TextMatrix(sRow, 0) = "Թ " & i + 1
        .TextMatrix(sRow, 1) = "Թ " & i + 10
        .TextMatrix(sRow, 2) = " " & i + 20
        .TextMatrix(sRow, 3) = Format(i + 30, "#,##0.00")
        .Rows = .Rows + 1 ' Ƿա 1
    End With
Next
fg.Rows = fg.Rows - 1 ' ҢͧѹԹ 1 ҹͧ ... ͧ鴴ҹǡѹ
End Sub

Sub SetupGrid() ' 駤ҵҧͧ FlexGrid
With fg
    .Clear '  Clear FlexGrid
    .Cols = 4 ' á˹ٻẺͧ Run Time Ѻ
    .TextMatrix(0, 0) = "Թ"
    .TextMatrix(0, 1) = "Թ"
    .TextMatrix(0, 2) = ""
    .TextMatrix(0, 3) = "Ҥ"
    .ColWidth(0) = 1200
    .ColWidth(1) = 3200
    .ColWidth(2) = 1000
    .ColWidth(3) = 1250
End With
End Sub

Private Sub Text1_Change() 
    '  Text1 Դ¹ŧ 觤Ѻ Cell ҵͧô йѧͧ͡Ѻ Text1 ѹѺ Cell -- Фѭеǹ
    fg.Text = Format(Text1.Text, "#,##0.00")
End Sub

 

ҧúҧѺ ͨͧ繷ҧҧ () ҧФѺ ûءҹҡ ҧ ¡觫 ʹҤ Ẻͺ ComboBox DTPicker ŧ ( ... ) ûҳ ҡ鹡Ӣŷ㹡Դ ŧ㹰ҹҧʺ ӹ¤дǡҹաҡ ... Դѹ

ػ

ش鹢ͧҹ鹹ѹԴҨҡ "Թҡ" ǹҼҹҡѺ "鹰ҹͧ Visual Basic" ҹ
  • Control Object
  • Properties - سѵԻШӵǢͧ Control Object
  • Method - Ըա ͹ (Move) ФѺ
  • Event - Driven Դ˵ءóâ Ǩѹ价 ...
  • Ǩ ???
  •  


    ͵ - g2gNet Dot Com
    Ţ¹ҳԪ硷͹ԡ 0407314800231
    CopyLeft © 2004 - 2099 g2gNet.Com All rights reserved.
    Email: [email protected] . 08-6862-6560