投稿日 | : 2005/03/03(Thu) 16:18 |
投稿者 | : ももたろう |
Eメール | : |
URL | : |
タイトル | : MSHFlexGridでの列幅自動調整について |
MSHFlexGridに表示した時に、列を読み込んだ文字列の長さに自動調整して
表示したいのですが、そういうことはできますか?
また、列は20列くらいあり、文字列の長さはまちまちで統一されていません。
下記に表示している部分のコードを明記します。
Dim strSQL As String
Dim i As Long
Dim rst As DAO.Recordset
Dim DB As DAO.Database
strSQL = "SELECT * FROM CR5000 WHERE SearchCode like '" & cboSearchCode.Text & _
"' and partName like '" & txtpartName.Text & _
"' and partcode like '" & txtPartCode.Text & _
"' and GTCode like '" & txtGTCode.Text & _
"' and Maker like '" & txtMaker.Text & _
"' and MakerCode like '" & txtMakerCode.Text & _
"' and value like '" & txtValue.Text & _
"' and NumberOfPin like '" & txtNumberOfPin.Text & "'"
Debug.Print strSQL
Set DB = OpenDatabase(App.Path & "\cr5000.mdb")
Set rst = DB.OpenRecordset(strSQL)
i = 1
frmMain.MSHFlexGrid1.Visible = False
frmMain.MSHFlexGrid1.ColAlignment(-1) = flexAlignLeftCenter '全ての値を左寄せ中央に
表示
With rst
'カレントレコードをテーブルの先頭に移動
Do While Not .EOF
With frmMain.MSHFlexGrid1
.AddItem ""
.TextMatrix(i, 0) = rst![RecommendedByIDC]
.TextMatrix(i, 1) = rst![partName]
.TextMatrix(i, 2) = rst![PartsClass]
.TextMatrix(i, 3) = rst![PartCode]
.TextMatrix(i, 4) = rst![GTCode]
.TextMatrix(i, 5) = rst![Maker]
.TextMatrix(i, 6) = rst![MakerCode]
.TextMatrix(i, 7) = rst![JapanesePartsName]
.TextMatrix(i, 8) = rst![EnglishPartsName]
.TextMatrix(i, 9) = rst![Price]
.TextMatrix(i, 10) = rst![DiscontinuedParts]
.TextMatrix(i, 11) = rst![NumberOfPin]
.TextMatrix(i, 12) = rst![Value]
End With
i = i + 1
.MoveNext
Loop
.Close
End With
frmMain.MSHFlexGrid1.Visible = True
DB.Close
Set rst = Nothing
Set DB = Nothing