投稿日 | : 2003/12/18(Thu) 11:38 |
投稿者 | : ak |
Eメール | : |
URL | : |
タイトル | : Re: SPREAD6.0Jについて |
> VB6.0 Win2000 SPREAD6.0Jで開発しています。
>
> ここで質問することではないのかもしれないのですが、
> SPREADに詳しい方はいないかなと思い、投稿しました。
>
> SPREADのイベントで境界線Clickというものはないのでしょうか?
> Excelと同じようなセル幅自動調整を作りたいと思っているのですが、
> 境界線のクリックが見つかりません。
> 返答お願いします。
RowHeightChange、ColWidthChangeイベントがそれに近いイベントだと思います。
詳細はヘルプを参照してください。
サンプルを記述しておきます。
注:サンプルはSpread3.0Jで作成しました。
6.0Jでも問題なく動くと思いますが6.0Jでは他に方法があるかもしれません。
'(*.frm) フォームにvaSpreadを1個配置してください。
Option Explicit
Private Type ptypSizeChange
ctColFlg As Boolean
ctRowFlg As Boolean
ctCol1 As Long
ctCol2 As Long
ctRow1 As Long
ctRow2 As Long
End Type
Private ptSzChg As ptypSizeChange
Private Sub Form_Load()
Dim ii As Integer
Dim lTmp As Long
Call psbVarInit '変数初期化
'フォーム初期設定
With Me
.Width = 5715
.Height = 3840
End With
'スプレッド初期設定
With vaSpread1
.Top = 15
.Left = 15
.Width = 5580
.Height = 3420
.MaxRows = 10
.MaxCols = 3
.FontSize = 12
lTmp = .MaxTextRowHeight(0)
.RowHeight(0) = lTmp
'データ作成
For ii = 1 To 10
Call .SetText(1, ii, String(Int(Rnd * 10) + 1, Chr(47 + ii)))
Call .SetText(2, ii, String(Int(Rnd * 10) + 1, Chr(64 + ii)))
Call .SetText(3, ii, String(Int(Rnd * 10) + 1, Chr(74 + ii)))
Next ii
End With
End Sub
Private Sub vaSpread1_Click(ByVal Col As Long, ByVal Row As Long)
Call psbVarInit '変数初期化
End Sub
Private Sub vaSpread1_ColWidthChange(ByVal Col1 As Long, ByVal Col2 As Long)
With ptSzChg
.ctColFlg = True
.ctCol1 = Col1
.ctCol2 = Col2
End With
End Sub
Private Sub vaSpread1_RowHeightChange(ByVal Row1 As Long, ByVal Row2 As Long)
With ptSzChg
.ctRowFlg = True
.ctRow1 = Row1
.ctRow2 = Row2
End With
End Sub
Private Sub vaSpread1_DblClick(ByVal Col As Long, ByVal Row As Long)
Dim lTmp As Long
Dim ii As Long
With vaSpread1
'列幅変更
If ptSzChg.ctCol1 <= Col And ptSzChg.ctCol2 >= Col And _
ptSzChg.ctColFlg And Row = 0 Then
For ii = ptSzChg.ctCol1 To ptSzChg.ctCol2
.Col = ii
If .UserResizeCol <> 2 Then
lTmp = .MaxTextColWidth(ii)
.ColWidth(ii) = lTmp
End If
Next ii
End If
'行幅変更
If ptSzChg.ctRow1 <= Row And ptSzChg.ctRow2 >= Row And _
ptSzChg.ctRowFlg And Col = 0 Then
For ii = ptSzChg.ctRow1 To ptSzChg.ctRow2
.Row = ii
If .UserResizeRow <> 2 Then
lTmp = .MaxTextRowHeight(ii)
.RowHeight(ii) = lTmp
End If
Next ii
End If
'Row、Colを元に戻す
.Row = Row
.Col = Col
End With
Call psbVarInit '変数初期化
End Sub
'変数初期化
Private Sub psbVarInit()
With ptSzChg
.ctColFlg = False
.ctCol1 = 0
.ctCol2 = 0
.ctRowFlg = False
.ctRow1 = 0
.ctRow2 = 0
End With
End Sub