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 컨트롤을 클릭한 후 필드별로 정렬할 수 있도록 해야 하는 경우도 있습니다. 이 글에서는 이 기능을 구현하는 방법에 대해 설명합니다. 1. 준비 작업: Wincc에서 32비트 부동소수점형의 내부 변수 Sort를 새로 만들어, 정렬 순서가 오름차순인지 내림차순인지를 표시하는 데 사용합니다.Wincc 페이지에 정적 텍스트를 삽입하고, 그 이름을 “txt”로 변경합니다. 속성 – 효과 – 전체 색상은 “아니오”로 설정하고, 속성 – 색상 – 배경색의 “투명도”는 100으로 설정합니다. 테두리의 굵기는 0으로 설정합니다.

다음으로, MSHFGrid 컨트롤의 이벤트인 “객체 이벤트 – 마우스 업”에 다음 스크립트를 입력합니다:

```vba
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.