당신이 색상 열거 찾고 있다면, 현재의 인덱스 값을 사용하여 각 셀에 다른 색상을 할당하려고한다고 가정 해 봅시다 :
' Get all the values from the KnownColor enumeration.
Dim colorsArray As System.Array = [Enum].GetValues(GetType(KnownColor))
Dim allColors(colorsArray.Length) As KnownColor
Array.Copy(colorsArray, allColors, colorsArray.Length - 1)
With dgvColors
.ReadOnly = True
.Columns.Add("ColorName", "ColorName")
For i = 0 To allColors.Length - 1
.Rows.Add(allColors(i).ToString)
.Rows(i).Cells(0).Style.BackColor = Color.FromKnownColor(allColors(i))
Next
.Columns("ColorName").Width = 500
.Rows.RemoveAt(.Rows.Count - 2) ' delete - bug in arrays
.Rows.RemoveAt(.Rows.Count - 2) ' delete - bug in arrays
.ClearSelection()
End With
을
이것은 DataGridView에 색상을 추가하는 해킹입니다. 이것이 합법적 인 코드인지는 모르지만 유틸리티로 사용합니다.
'데이터 구조'가 아니라 Excel 워크 시트의 셀 집합입니다. 그것은 당신이 물어 보는 것이 분명하지 않기 때문에 당신의 질문을 다시 말해 줄 것입니다. – Robin
. ws는 무엇을 나타 냅니까? 당신은 세포를 통해 잘 반복 될 수있는 것처럼 보입니다 (ws가 무엇인지에 따라 다름). – rheitzman