投稿日 | : 2004/01/27(Tue) 15:13 |
投稿者 | : 花ちゃん |
Eメール | : |
URL | : |
タイトル | : Re: MSflexgridの表示について |
▲と▼ の書いたPictureをクリックの都度表示切替して下さい。
MSFlexGridでセルの背景色の塗りつぶしのパターンを設定 等を参照
> また、表の右や下に余計なグレーエリアが出ているのでこれを消したいので
> すができますか?
各セルの幅を計算して表示サイズを設定して下さい。
下記コードを試して見て下さい。
Form に MSFlexGrid と CommandButton を貼り付けておいて下さい。
Option Explicit
Private Sub Form_Load()
Dim i As Long
With MSFlexGrid1
.AllowUserResizing = flexResizeBoth
.Cols = 6
.Rows = 10
.ColWidth(3) = 1500
.TextMatrix(0, 3) = "ファイル名 ▲"
.Move 400, 400, 6500, 3000
For i = 1 To .Rows - 1
.TextMatrix(i, 3) = i * 10
Next i
.AllowBigSelection = False
End With
End Sub
Private Sub Command1_Click()
Dim TotalHeight As Long
Dim TotalWidth As Long
Dim i As Long
With MSFlexGrid1
For i = 0 To .Cols - 1
TotalWidth = TotalWidth + .ColWidth(i)
Next i
For i = 0 To .Rows - 1
.Row = i
TotalHeight = TotalHeight + .RowHeight(i)
Next i
.Width = TotalWidth + 100 '左右の余白分(100)をプラス
.Height = TotalHeight + 100 '上下のの余白分(100)をプラス
End With
End Sub
Private Sub MSFlexGrid1_Click()
With MSFlexGrid1
If .MouseCol = 3 And .MouseRow = 0 Then
If .TextMatrix(0, 3) = "ファイル名 ▲" Then
.TextMatrix(0, 3) = "ファイル名 ▼"
.Col = 3
.Sort = flexSortGenericAscending
Else
.TextMatrix(0, 3) = "ファイル名 ▲"
.Col = 3
.Sort = flexSortGenericDescending
End If
End If
End With
End Sub