HCBBS Forum (日本語)
Submit Chemical Projects / Find Solutions
Amplify Your Requirements on a Broader Chemical Platform *Engineering · Technology · Equipment · Solutions*
Submit Request

Winccスクリプト例3-MSHFGridコントロールによるレコードのフィールド別ソート

2016-04-16View Original

Thread Content

場合によっては、操作者がMSHFGridコントロールをクリックした後、フィールドごとに並べ替えができるようにする必要があります。本稿では、この機能の実現方法について解説します。 一 準備作業 Winccで32ビットの浮動小数点型の内部変数Sortを新規作成し、昇順か降順かを示すために使用する。Winccのページに静的テキストを挿入し、名前を「txt」と変更します。属性の「効果」タブで「グローバル色」を「いいえ」に設定し、「色」タブの「背景色」の「透明度」を100に、「枠の太さ」を0にします。

二 ソートスクリプト
MSHFGridコントロールのイベントである「オブジェクトイベント-mouseup」に、以下のスクリプトを記述します。

Dim MSHFGrid, txt, sort
Set MSHFGrid = ScreenItems("MSHFGrid")
Set sort = HMIRuntime.Tags("Sort")
Set txt = ScreenItems("txt")

If MSHFGrid.TextMatrix(0, item.MouseCol) = "日時" Then
If sort.Read = 2 Then
MSHFGrid.Sort = 1 '数値の昇順で並べ替え
sort.Write 1
txt.Text = "現在、「" & MSHFGrid.TextMatrix(0, item.MouseCol) & "」フィールドに基づき昇順で並べ替えています"
Else
MSHFGrid.Sort = 2 '数値の降順で並べ替え
sort.Write 2
txt.Text = "現在、「" & MSHFGrid.TextMatrix(0, item.MouseCol) & "」フィールドに基づき降順で並べ替えています"
End If
Else If sort.Read = 2 Then
MSHFGrid.Sort = 5 '文字の昇順で並べ替え
sort.Write 1
txt.Text = "現在、「" & MSHFGrid.TextMatrix(0, item.MouseCol) & "」フィールドに基づき昇順で並べ替えています"
Else
MSHFGrid.Sort = 6 '文字の降順で並べ替え
sort.Write 2
txt.Text = "現在、「" & MSHFGrid.TextMatrix(0, item.MouseCol) & "」フィールドに基づき降順で並べ替えています"
End If

End Sub

保存して実行すると、効果が確認できます。このスクリプトは前回のブログのプロジェクトをベースに作成されています。MSHFGridをデータテーブルにどのように接続するかについては、他のWinCCスクリプトに関する推奨記事を参照してください。
Reply #22016-04-17
パッケージファイルをアップロードできますか?

Submit a Project

**Looking for Chemical Technology, Equipment & Solutions?** No Registration Required Broader Platform Exposure | Global Chemical Service Provider Connections

Submit Request — Free Consultation

Disclaimer

This is an automated machine translation of the original thread. Some technical terms may have inaccuracies; the original text shall prevail. Click "View Original" at the top right to access the source page, which supports IP-based automatic real-time language translation. Please watch out for contact details and sales inducements to prevent fraud. All content and translations are for reference only, representing solely the poster's personal views. For enquiries, email service@hcbbs.com.