FLEXGRID 설명
펌 - http://blog.naver.com/PostView.nhn?blogId=jsluvhy&logNo=101987161
관련사이트 - http://flexigrid.info/
1. 상위,하위 행번호 return
FG1.GetNodeRow(FG1.Row,0)
parameter : row(행번호), 옵션(0:가장 상위 parent, 1:상위parent .. 등등)
설명 : 현제 row의 상위(parent) row번호를 리턴한다.
참조(API)
FlexNTRoot |
0 |
Returns the index of the node's top level ancestor. |
FlexNTParent |
1 |
Returns the index of the node's immediate parent. |
FlexNTFirstChild |
2 |
Returns the index of the node's first child node. |
FlexNTLastChild |
3 |
Returns the index of the node's last child node. |
FlexNTFirstSibling |
4 |
Returns the index of the node's first sibling node (may be same row) |
FlexNTLastSibling |
5 |
Returns the index of the node's last sibling node (may be same row) |
FlexNTPreviousSibling |
6 |
Returns the index of the node's previous sibling node (-1 if this is the first sibling) |
FlexNTNextSibling |
7 |
Returns the index of the node's next sibling node (-1 if this is |
2. Cell color변경
FG1.Cell(6, i, 0) = 0xfff4dd;
parameter : 옵션, (시작)row번호, (시작)cell번호, [끝 row번호], [끝 cell번호]
설명 : 백그라운드 색갈을 바꾼다. 옵션에 따라 색갈뿐만 아니라 여러가지 (foreGroundcolor등..) 도 바꿀수 있다.
CELL함수 옵션에 따라 여러가지 기능을 표현할수 있다. 참고로 7은 글자색일껄... 13은 BOLD...
row 전체를 할경우 [ ex) gridList.Cell(6, i, 0, i, gridList.Cols-1) = 0xfff4dd;]
2-1. Cell font Bold
gridList.Cell(13, row, 0, row, gridList.Cols-1) = true;
설명 : font를 Bold로 지정
2-1. Cell 의 이전값 가져오기
var aa = FG1.Cell(20, i, 0)
parameter : 옵션, row번호, cell번호
설명 : 수정전 값을 가져온다.
3. 포커스 이동
FG2.ShowCell(row,1);
parameter : row번호, cell번호.
설명 : 포커스지정, 포커스가있는곳으로 스크롤바 위치 변경
4. 더블클릭했을때 수정여부 설정
FG1.Editable = flexEDKbdMouse; //수정가능 2
FG1.Editable = flexEDNone; //수정불가 0
설명 : 폴더 수정가능, 수정 불가
5. ROW 삭제
FG1.RemoveItem(FG1.Row); //선택한 행 삭제
6. 좌우정렬
FG1.Col = FG1.ColIndex("PASSWORD"); //row 선택
FG1.CellAlignment = flexAlignLeftCenter; //해당 row left 정렬
7. 체크박스
FG1.ColDataType(7) = flexDTBoolean; // 컬럼[7]의 타입을 CHECK_BOX로 선언.
FG1.AddItem()을 할때 값을 0으로 준다. (그럼 체크되지 않은 체크박스가 해당행에 생성된다)
FG1.Editable = flexEDKbdMouse; // Editable 을 해야 체크를 할수 있다.
설명 : 해당행을 CHECKBOX 로 생성
8. 셀값을 가져온다.
FG1.TextMatrix(i, 7)
parameter : row(행번호), CELL(열번호)
설명 : 해당셀의 값을 return
9. 전체 row count값을 return
FG1.Rows
설명 : 아래와 같이 모든행의 count를 가져올때 쓴다.
for(var i=1; i<FG1.Rows; i++)
{
val = FG1.TextMatrix(i, 0);
}
CELL의 전체COUNT를 가져오려면...FG1.Cols 이거겠지...
10. cell index를 구한다.
FG1.ColIndex("타이틀");
설명 : 파리미터에 컬럼명을 넣으면 cell index를 return 한다.
주의 : 만약 VsFlexGridScript.js 를 사용한다면 "E"를 추가해서 넣어라.
예로 FG1.ColIndex("E타이틀") 이런식으로 말이다.
E가 아니고 다른것도 붙을수 있다. 자세한건 나한테 물어라....
11. 타이틀을 변경하거나 타이틀값을 가져온다.
FG1.TextArray(0) = "타이틀";
파라미터 : CELL INDEX
설명 : 타이틀을 변경하거나 타이틀 값을 가져올때 사용한다.
단 이것은 ColIndex(컬럼키)의 컬럼키와 다른 단순한 name일뿐이다.
11-1 Column index에 해당하는 Key를 가져온다.
var colName = gridList.ColKey(j);
12. 행 위치를 이동한다.
FG1.RowPosition(1) = 2;
파라미터 : ROW INDEX
설명 : 한마디로 1 ROW 를 2번자리로 옮기고 2번놈은 1번놈으로 가라. 이런거지..
13. TREE 형태로 표현
FG1.OutlineBar = 2;
FG1.OutlineCol = gridList.ColIndex("WBS"); // WBS란 컬럼을 트리로 지정한다.
일단 위 두줄에 구문을 실행한다.
FG1.IsSubtotal(FG1.Rows - 1) = true;
FG1.RowOutlineLevel(FG1.Rows - 1) = level;
위 두 구문은 TREE에서 공식과 같은 구문이다.
ROW를 하나씩 그릴때마 이구문은 무조건적으로 들어가야한다.
이구분을 빼면 그냥 테이블 형태로 그려질껄...
13-1. Tree를 열다/닫다
// 몇번 행의 트리를 열어라.
FG1.IsCollapsed(nodeRowNum) = 0; //0모두 열고, 1은.. 2...
14. row에 hidden 값을 준다..??
FG1.RowData(0) = "abcd";
설명 : 행마다 보이지 않는 특별한 값을 준다.... 불필요할꺼같은데.. 일단 적어놓자.. 기록은 필수.!!
이걸 설명해놓으면 FG1.RowData(i)라는 걸로 검색이 되는데 이건 할줄모르겠당...
15. cursor 위치를 옮긴다.
FG1.Row = 5 <== 커서를 5번째줄로 이동
16. ROW 추가
FG2.AddItem (mvArray[i].NAME, j+1); // 명칭(\t 구분), 행
FG2.IsSubtotal(j+1) = true; // 이거랑 아래껀 그냥 셋트라고 생각해라.
FG2.RowOutlineLevel(j+1) = 3; // level를 넣는다.
17. 셀 병합
FG2.MergeCells = 4;
FG2.MergeCol(-1) = true;
설명 : AddItem 이 같은 셀(세로)을 병합한다.
FG2.MergeCells = 1;
FG2.MergeRow(-1) = true;
설명 : AddItem 이 같은 셀(가로)을 병합한다.
18. Row의 Level 구하기
VSFlexGrid.(Row As Long) [ = value As Integer ]
19. fixed 된 row를 구한다. & 설정한다.
설명 : header부분다음줄 즉 fixed된 row를 구한다.
FG1.gridList.FixedRows;
FG1.FixedRows = 2;
20. COMBO BOX
설명 : 특정 컬럼을 COMBO로 설정
문법 : VSFlexGrid. (Col As Long)[ = value As String ]
예제 : fg.ColComboList(1) = "#1;Full time|#23;Part time|#65;Contractor|#78;Intern|#0;Other"
21. row를 감춘다.
gridList.RowHidden(row) = "True";
22. col을 감춘다.
gridList.ColHidden(col) = "True";
23. formatting
VSFlexGrid.ColFormat(Col As Long)[ = value As String ]
Format Content Display
----------- ----------- -------------
#,###.## 1234.56 1,234.56
24. 해당 행/열 선택
VSFlexGrid.Select(i, j);
설명 : i 는 row 고 j는 셀이다. i 행의 j 열을 선택한다. 보통 (3. 포커스 이동)과 함께 쓰인다.
25. Cell에 프로그래스 바 표시
gridList.Cell(flexcpFloodPercent, Row, Col) = 50 <========= 50%를 표시
gridList.FloodColor = 0xfec8c5; <============= 프로그래스바 색
26. SelectionMode
gridList.SelectionMode = 3;
설명 : 그리드를 선택 즉 클릭 했을때 선택되어 보여지는 범위를 설정한다.
옵션 : 0 : (default) 아무것도 선택 안한다.
1 : row
2 : Column
3 : row + Ctrl기능 사용가능
27. 제목 표시줄 (Head, (Title)) 또는 Row 을 숨긴다.
FG1.RowHidden(0) = true; // 위에 제목표시줄을 없엔다.
28. Column을 숨긴다.
FG1.ColHidden([colIndex]) = true;
29. GRID 전체 수정, 비수정 모드
gridList.Editable = 0; //수정 불가. 보통 EnterCell Event와 함께 쓴다.
=========================== EVENT ============================
1. AfterEdit(row, col)
- KeyIn이 완료 되었을때 시점
-----------------------------------------------------------------------------------------------------------------------
본 소스에 주석처리를 해놓았습니다. 아마 이걸 이용해서 엑셀만한 기능은 못될지언정 비스무리 하게 만들 수는 있을 것 같네요.
소스내용은 MSHFlexGrid와 텍스트 박스를 이용해서 현재 선택된 셀에 텍스트 박스를 위치시켜 값을 입력받을 수 있게 하며
마우스 포인터가 다른 셀등으로 빠져 나갔을 경우 입력한 값을 셀에 입력합니다.
더 응용해서 1, 2, 3번째 셀에 숫자값을 입력하면 바로바로 5번째 셀에 1, 2, 3셀의 값을 더해서 뿌려줍니다.
4번째 셀은 마우스가 가도 입력되지 못하는 코드를 추가했습니다.
아래는 젤 중요한 대목입니다. 사실 이 코드 밖에 없죠.
Dim PrevRow As Byte
Dim PrevCol As Byte '이전에 선택된 셀
Dim SelRow As Byte
Dim SelCol As Byte '선택된 셀 저장
Private Sub XpathGrid_Click()
Dim i As Byte
TxtInput.Text = ""
TxtInput.SetFocus
If XpathGrid.MouseCol = 0 Or XpathGrid.MouseRow = 0 Then Exit Sub
'현재 선택한 셀이 0,0이면 그냥 빠져나갑니다.
If XpathGrid.MouseCol = 4 Then Exit Sub
'4번째 Col셀일 경우 입력받지 못하게 합니다.
SelRow = XpathGrid.MouseRow - 1 '현재 선택한 Row값을 구합니다.
SelCol = XpathGrid.MouseCol - 1 '현재 선택한 Col값을 구합니다.
TxtInput.Top = XpathGrid.Top + (XpathGrid.RowHeight(XpathGrid.MouseRow) * XpathGrid.MouseRow) + 25
'현재 텍스트 박스의 Top의 위치를 구합니다.
TxtInput.Left = XpathGrid.Left + (XpathGrid.ColWidth(XpathGrid.MouseCol) * XpathGrid.MouseCol) - 65
'현재 텍스트 박스의 Left의 위치를 구합니다.
PrevCol = XpathGrid.MouseCol: PrevRow = XpathGrid.MouseRow
'현재 선택한 셀의 위치를 이전위치변수값에 저장합니다.
End Sub
Private Sub XpathGrid_LeaveCell()
'셀에서 포커스가 뜨게 되면
XpathGrid.TextMatrix(PrevRow, PrevCol) = TxtInput.Text '텍스트 박스에 입력한 값을 셀에 입력합니다.
XpathGrid.CellAlignment = flexAlignCenterCenter '가운데 위치하도록
TxtInput.Move 4460, 4270 '텍스트 박스를 안보이는 곳으로 위치
XpathGrid.TextMatrix(PrevRow, 5) = Val(XpathGrid.TextMatrix(PrevRow, 1)) + Val(XpathGrid.TextMatrix(PrevRow, 2)) + Val(XpathGrid.TextMatrix(PrevRow, 3))
'값을 더해 맨우측에 값을 넣습니다. Val()는 문자는 0으로 취급합니다. 예외오류 사항 체크는 IsNumeric()함수로 하시면 되겠죠?
End Sub
참고로 MSDN에 있는 MSGFlexGrid의 상수값도 참고해보세요
참고. MSHFlexGrid 컨트롤 상수 (MSDN에서 발췌합니다.)
이 절에는 MSHFlexGrid의 컨트롤 상수를 설명합니다. 다른 언급이 없을 경우 이들 상수는 MSFlexGrid에도 적용할 수 있습니다.
AddModeSettings 속성(MSHFlexGrid)
상수 값 설명
flexNoAddNew 0 현재 셀이 마지막 행에 있지 않고 보류 중인 AddNew 작업도 없습니다.
flexAddNewCurrent 1 현재 셀이 마지막 행에 있지만 보류 중인 AddNew 작업은 없습니다.
flexAddNewPending 2 현재 셀이 마지막 행 다음에 있습니다. 이것은 MSHFlexGrid의 사용자 인터페이스를 통해 사용자가 시작한 보류 AddNew 작업의 결과이거나 프로그램적으로 열의 Value나 Text 속성을 설정한 결과입니다.
AllowUserResizing 속성
상수 값 설명
flexResizeNone 0 마우스로 크기를 재조정할 수 없습니다. 기본값입니다.
flexResizeColumns 1 마우스로 열의 크기를 재조정할 수 있습니다.
flexResizeRows 2 마우스로 행의 크기를 재조정할 수 있습니다.
flexResizeBoth 3 마우스로 열과 행의 크기를 재조정할 수 있습니다.
Appearance 속성
상수 값 설명
flexFlat 0 MSHFlexGrid의 전체 모양이 평면이거나 표준입니다.
flex3D 1 MSHFlexGrid의 전체 모양이 3차원입니다.
BorderStyle 속성
상수 값 설명
flexBorderNone 0 테두리가 없습니다.
flexBorderSingle 1 단일 테두리입니다.
CellAlignment 속성
상수 값 설명
flexAlignLeftTop 0 셀 내용을 왼쪽 위로 맞춥니다.
flexAlignLeftCenter 1 셀 내용을 왼쪽 가운데로 맞춥니다. 문자열에 대한 기본값입니다.
flexAlignLeftBottom 2 셀 내용을 왼쪽 아래로 맞춥니다.
flexAlignCenterTop 3 셀 내용을 가운데 위로 맞춥니다.
flexAlignCenterCenter 4 셀 내용을 중앙에 놓습니다.
flexAlignCenterBottom 5 셀 내용을 가운데 아래로 맞춥니다.
flexAlignRightTop 6 셀 내용을 오른쪽 위로 맞춥니다.
flexAlignRightCenter 7 셀 내용을 오른쪽 가운데로 맞춥니다. 숫자에 대한 기본값입니다.
flexAlignRightBottom 8 셀 내용을 오른쪽 아래로 맞춥니다.
flexAlignGeneral 9 셀 내용을 일반적인 맞춤 방법으로 정렬합니다. 문자열에 대해서는 "왼쪽 가운데"로 숫자에 대해서는 "오른쪽 가운데"로 맞춥니다.
CellPictureAlignment 속성
상수 값 설명
flexAlignLeftTop 0 그림을 왼쪽 위로 맞춥니다.
flexAlignLeftCenter 1 그림을 왼쪽 가운데로 맞춥니다.
flexAlignLeftBottom 2 그림을 왼쪽 아래로 맞춥니다.
flexAlignCenterTop 3 그림을 가운데 위로 맞춥니다.
flexAlignCenterCenter 4 그림을 중앙에 놓습니다.
flexAlignCenterBottom 5 그림을 가운데 아래로 맞춥니다.
flexAlignRightTop 6 그림을 오른쪽 위로 맞춥니다.
flexAlignRightCenter 7 그림을 오른쪽 가운데로 맞춥니다.
flexAlignRightBottom 8 그림을 오른쪽 아래로 맞춥니다.
CellTextStyle, TextStyle, TextStyleFixed 속성
상수 값 설명
flexTextFlat 0 표준 평면 텍스트입니다.
flexTextRaised 1 텍스트가 볼록하게 표시됩니다.
flexTextInset 2 텍스트가 오목하게 표시됩니다.
flexTextRaisedLight 3 텍스트가 약간 볼록하게 표시됩니다.
flexTextInsetLight 4 텍스트가 약간 오목하게 표시됩니다.
CellType 속성(MSHFlexGrid)
상수 값 설명
flexCellTypeStandard 0 표준 셀입니다.
flexCellTypeFixed 1 고정된 행이나 열에 포함된 셀입니다.
flexCellTypeHeader 2 데이터 밴드의 머리글 셀입니다.
flexCellTypeIndent 3 데이터 밴드를 들여쓰기하는 열에서 사용하는 셀입니다.
flexCellTypeUnpopulated 4 채워지지 않는 셀입니다.
ColAlignment 속성
상수 값 설명
flexAlignLeftTop 0 열 내용을 왼쪽 위로 맞춥니다.
flexAlignLeftCenter 1 열 내용을 왼쪽 가운데로 맞춥니다. 문자열에 대한 기본값입니다.
flexAlignLeftBottom 2 열 내용을 왼쪽 아래로 맞춥니다.
flexAlignCenterTop 3 열 내용을 가운데 위로 맞춥니다.
flexAlignCenterCenter 4 열 내용을 중앙에 놓습니다.
flexAlignCenterBottom 5 열 내용을 가운데 아래로 맞춥니다.
flexAlignRightTop 6 열 내용을 오른쪽 위로 맞춥니다.
flexAlignRightCenter 7 열 내용을 오른쪽 가운데로 맞춥니다. 숫자에 대한 기본값입니다.
flexAlignRightBottom 8 열 내용을 오른쪽 아래로 맞춥니다.
flexAlignGeneral 9 열 내용을 일반적인 맞춤 방법으로 정렬합니다. 문자열에 대해서는 왼쪽 가운데로 숫자에 대해서는 오른쪽 가운데로 맞춥니다.
ColHeader 속성(MSHFlexGrid)
상수 값 설명
FlexColHeaderOn 0 각 밴드에 머리글을 표시합니다.
flexColHeaderOff 1 밴드에 머리글이 표시되지 않습니다.
flexColHeaderOnce 2 밴드에 머리글을 표시합니다. 밴드가 축소되면 한 개의 머리글만 표시됩니다. 이중 머리글은 표시되지 않습니다.
DisplayBandSettings 속성(MSHFlexGrid)
상수 값 설명
flexBandDisplayHorizontal 0 MSHFlexGrid내의 밴드가 수평으로(가로질러) 표시됩니다. 기본값입니다.
flexBandDisplayVertical 1 MSHFlexGrid내의 밴드가 수직으로(위 아래로) 표시됩니다.
DisplayCellSettings 속성(MSHFlexGrid)
상수 값 설명
FlexCellDisplayHorizontal 0 MSHFlexGrid내의 밴드가 수평으로(가로질러) 표시됩니다.
flexCellDisplayVertical 1 MSHFlexGrid내의 밴드가 수직으로(위 아래로) 표시됩니다.
FillStyle 속성
상수 값 설명
flexFillSingle 0 단일. Text나 셀의 속성을 변경할 경우 활성 셀만 영향을 받습니다. 기본값입니다.
flexFillRepeat 1 반복. Text나 셀의 속성을 변경할 경우 선택된 모든 셀이 영향을 받습니다.
FocusRect 속성
상수 값 설명
flexFocusNone 0 현재 셀 주위에 포커스 사각형을 표시하지 않습니다.
flexFocusLight 1 현재 셀 주위에 가는 포커스 사각형을 표시합니다. 기본값입니다.
flexFocusHeavy 2 현재 셀 주위에 굵은 포커스 사각형을 표시합니다.
GridLines, GridLinesFixed 속성
상수 값 설명
flexGridNone 0 선 없음. 셀 사이에 선이 없습니다. MSFlexGrid에서 GridLines의 기본값입니다.
flexGridFlat 1 선. 셀 사이의 선 유형이 표준 평면 선으로 설정됩니다. MSHFlexGrid에서 GridLines의 기본값입니다.
flexGridInset 2 오목한 선. 셀 사이의 선 유형이 오목한 선으로 설정됩니다. MSFlexGrid에서 GridLinesFixed의 기본값입니다.
flexGridRaised 3 볼록한 선. 셀 사이의 선 유형이 볼록한 선으로 설정됩니다. MSHFlexGrid에서 GridLinesFixed의 기본값입니다.
HighLight 속성
상수 값 설명
flexHighlightNever 0 선택된 셀을 반전하지 않습니다.
flexHighlightAlways 1 선택된 셀을 항상 반전합니다. 기본값입니다.
FlexHighlightWithFocus 2 컨트롤에 포커스가 있을 경우에만 반전합니다.
MergeCells 속성
상수 값 설명
flexMergeNever 0 병합 안함. 동일한 내용을 가진 셀들을 그룹화하지 않습니다. 기본값입니다.
flexMergeFree 1 자유. 동일한 내용을 가진 셀들을 항상 병합합니다.
flexMergeRestrictRows 2 행 제한. 행 내에서 동일한 내용을 갖는 인접 셀(현재 셀의 왼쪽에 있는)만 병합합니다.
flexMergeRestrict-Columns 3 열 제한. 열 내에서 동일한 내용을 갖는 인접 셀(현재 셀의 위에 있는)만 병합합니다.
flexMergeRestrictBoth 4 모두 제한. 행이나 열 내에서 동일한 내용을 갖는 인접 셀(현재 셀의 왼쪽 또는 위에 있는)만 병합합니다.
MousePointer 속성
상수 값 설명
flexDefault 0 MSHFlexGrid의 윤곽
flexArrow 1 화살표
flexCross 2 십자 모양
flexIBeam 3 텍스트 입력을 위한 I형
flexIcon 4 정사각형 내의 정사각형
flexSize 5 위, 아래, 왼쪽, 오른쪽을 가리키는 화살표 모양의 크기 조정 포인터
flexSizeNESW 6 오른쪽 위와 왼쪽 아래를 가리키는 화살표 모양의 크기 조정 포인터
flexSizeNS 7 위와 아래를 가리키는 화살표 모양의 크기 조정 포인터
flexSizeNWSE 8 왼쪽 위와 오른쪽 아래를 가리키는 화살표 모양의 크기 조정 포인터
flexSizeEW 9 왼쪽과 오른쪽을 가리키는 화살표 모양의 크기 조정 포인터
flexUpArrow 10 위쪽 화살표
flexHourGlass 11 모래 시계 모양
flexNoDrop 12 포인터 놓기 못함
flexCustom 13 사용자 정의 포인터
PictureType 속성
상수 값 설명
flexPictureColor 0 전체 색상을 사용한 고품질의 이미지를 만듭니다.
flexPictureMonochrome 1 메모리를 적게 사용하는 저품질의 단색 이미지를 만듭니다.
RowSizingSettings 속성(MSHFlexGrid)
상수 값 설명
flexRowSizeIndividual 0 행의 크기를 재조정할 경우 조정된 행만 높이가 변경됩니다. 기본값입니다.
flexRowSizeAll 1 행의 크기를 재조정할 경우 MSHFlexGrid의 모든 행 높이가 변경됩니다.
SelectionMode 속성
상수 값 설명
flexSelectionFree 0 자유. MSHFlexGrid의 각 셀을 스프레드시트 유형으로 선택할 수 있습니다. 기본값입니다.
flexSelectionByRow 1 행 단위. 다중 열 목록 상자나 레코드 단위로 표시할 때처럼 전체 행 단위로만 선택할 수 있습니다.
flexSelectionByColumn 2 열 단위. 차트의 범위를 선택하거나 정렬을 위해 필드를 선택할 때처럼 열 단위로만 선택할 수 있습니다.
ScrollBars 속성
상수 값 설명
flexScrollNone 0 MSHFlexGrid에 스크롤 막대가 없습니다.
flexScrollHorizontal 1 MSHFlexGrid에 수평 스크롤 막대를 둡니다.
flexScrollVertical 2 MSHFlexGrid에 수직 스크롤 막대를 둡니다.
flexScrollBoth 3 MSHFlexGrid에 수평 및 수직 스크롤 막대를 둡니다. 기본값입니다.
Sort 속성
상수 값 설명
flexSortNone 0 없음. 정렬하지 않습니다.
flexSortGenericAscending 1 일반 오름차순. 텍스트가 문자열인지 숫자인지를 예측하는 오름차순 정렬을 수행합니다.
flexSortGenericDescending 2 일반 내림차순. 텍스트가 문자열인지 숫자인지를 예측하는 내림차순 정렬을 수행합니다.
flexSortNumericAscending 3 숫자 오름차순. 문자열을 숫자로 변환하는 오름차순 정렬을 수행합니다.
flexSortNumericDescending 4 숫자 내림차순. 문자열을 숫자로 변환하는 내림차순 정렬을 수행합니다.
flexSortStringNoCaseAsending 5 문자열 오름차순. 대/소문자를 구분하지 않는 문자열 비교를 사용하는 오름차순 정렬을 수행합니다.
flexSortNoCaseDescending 6 문자열 내림차순. 대/소문자를 구분하지 않는 문자열 비교를 사용하는 내림차순 정렬을 수행합니다.
flexSortStringAscending 7 문자열 오름차순. 대/소문자 구분 문자열 비교를 사용하는 오름차순 정렬을 수행합니다.
flexSortStringDescending 8 문자열 내림차순. 대/소문자 구분 문자열 비교를 사용하는 내림차순 정렬을 수행합니다.
flexSortCustom 9 사용자 정의. Compare 이벤트를 사용하여 행을 비교합니다.
====================================================================================================================
BASIS
이 예제를 완성하려면 비주얼 베이직에서 팝업 메뉴를 표시하는 방법과 FlexGrid에서 칼럼을 추가하거나 삭제하는 간단한 방법에 대해 알아야 한다. 당연하게도(^^).... 참고문헌 [1], [2]에서 각 방법에 대한 친절한 설명을 찾을 수 있었다. 아래에 퍼왔으니 참고하시길...
Visual Basic also supports pop-up menus, those context-sensitive menus that most commercial applications show when you right-click on an user interface object. In Visual Basic, you can display a pop-up menu by calling the form's PopupMenu method, typically from within the MouseDown event procedure of the object:
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button And vbRightButton Then ' User right-clicked the list box. PopupMenu mnuListPopup End If End Sub |
The argument you pass to the PopupMenu method is the name of a menu that you have defined using the Menu Editor. This might be either a submenu that you can reach using the regular menu structure or a submenu that's intended to work only as a pop-up menu. In the latter case, you should create it as a top-level menu in the Menu Editor and then set its Visible attribute to False. If your program includes many pop-up menus, you might find it convenient to add one invisible top-level entry and then add all the pop-up menus below it. (In this case, you don't need to make each individual item invisible.) The complete syntax of the PopupMenu method is quite complex:
By default, pop-up menus appear left aligned on the mouse cursor, and even if you use a right-click to invoke the menu you can select a command only with the left button. You can change these defaults using the Flags argument. The following constants control the alignment: 0-vbPopupMenuLeftAlign (default), 4-vbPopupMenuCenterAlign, and 8-vbPopupMenuRightAlign. The following constants determine which buttons are active during menu operations: 0-vbPopupMenuLeftButton (default) and 2-vbPopupMenuRightButton. For example, I always use the latter because I find it natural to select a command with the right button since it's already pressed when the menu appears:
PopupMenu mnuListPopup, vbPopupMenuRightButton
The x and y arguments, if specified, make the menu appear in a particular position on the form, rather than at mouse coordinates. The last optional argument is the name of the menu that's the default item for the pop-up menu. This item will be displayed in boldface. This argument has only a visual effect; If you want to offer a default menu item, you must write code in the MouseDown event procedure to trap double-clicks with the right button.
Moves a given column to a new position.
[form!]vsFlexGrid.ColPosition(Col As Long)[ = NewPosition As Long ]
The Col and NewPosition parameters must be valid column indices (in the range 0 to Cols - 1), or an error will be generated.
with it, including width, height, alignment, colors, fonts, etc. To move text only, use the Clip property instead. The ColPosition property gives you programmatic control over the column order. You may also use the ExplorerBar property to allow users to move columns with the mouse.
Private Sub FG_MouseUp(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button And vbRightButton Then ' 과목명 셀을 클릭할 때만 팝업 메뉴를 표시한다. If (FG.MouseRow = 1) And (FG.MouseCol > 1) And (FG.MouseCol < FG.Cols - 2) Then ' 선택한 느낌이 들도록.... FG.Col = FG.MouseCol FG.Row = FG.MouseRow + 1 FG.RowSel = FG.Rows - 1 FG.ColSel = FG.MouseCol ' 팝업 메뉴 표시함. PopupMenu mnuGridPopup End If End If End Sub |
Private Sub mnuInsertColumn_Click() With FG ' insert column Dim str As String str = InputBox("과목명을 입력하세요") If str <> "" Then .Cols = .Cols + 1 ' add column .ColPosition(.Cols - 1) = .Col ' move into place .Cell(flexcpText, 1, .Col) = str .Cell(flexcpAlignment, 1, .Col) = flexAlignCenterCenter .Cell(flexcpText, 0, .Col) = "과목" End If End With End Sub |
Private Sub mnuRemoveColumn_Click() With FG ' delete column .ColPosition(.Col) = .Cols - 1 ' move to right .Cols = .Cols - 1 ' delete column ' 칼럼이 삭제됐으므로 계산을 다시 수행한다. Dim nTotal As Integer Dim dAverage As Single For i = 2 To .Rows - 1 nTotal = .Aggregate(flexSTSum, i, 2, i, .Cols - 3) dAverage = .Aggregate(flexSTAverage, i, 2, i, .Cols - 3) .Cell(flexcpText, i, .Cols - 2) = CStr(nTotal) .Cell(flexcpText, i, .Cols - 1) = Format(dAverage, "#,##.0") Next End With End Sub |