112. 리스트뷰(ListView)
.NET프로그래밍/WinForm 2009. 8. 28. 15:58 |* 리스트뷰(ListView)는 윈도우탐색기의 위쪽에 위치한 부분을 말한다.
'도구상자'의 '모든 Windows Forms'에서 "ListView"를 폼에 드래그 & 드롭 --> "Columns"속성에 들어가서 "컬렉션 편집기"로 편집 --> 'View'속성을 "Details"로 바꿈.
==> Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MyWinForms
{
static class Program
{
/// <summary>
/// 해당 응용 프로그램의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Controls.FrmListView());
}
}
}
==============================================================================================
==> FrmListView.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyWinForms.Controls
{
public partial class FrmListView : Form
{
public FrmListView()
{
InitializeComponent();
}
private void FrmListView_Load(object sender, EventArgs e)
{
// 국어/영어/총점을 리스트뷰에 출력
string[,] arr =
new string[,]
{
{"100", "100", "200"},
{"90", "90", "180"},
{"80", "80", "160"}
};
// 3개의 레코드를 리스트뷰에 출력
string[] arr1 = new string[] { "100", "100", "200" };
string[] arr2 = new string[] { "90", "90", "180" };
string[] arr3 = new string[] { "80", "80", "160" };
// 입력
this.lstScore.Items.Add(new ListViewItem(arr1)); //[1]번째 방법
ListViewItem lvi = new ListViewItem(arr2);// [2]번째 방법
this.lstScore.Items.Add(lvi);
this.lstScore.Items.Add(
new ListViewItem(new string[] { "80", "80", "160" })); //[3]번째 방법
}
}
}
< 실행결과 >
--> "ListView"의 "Columns"속성에서 "컬렉션 편집기"로 내용변경
--> "View"속성도 Details로 변경
--> 출력화면
'.NET프로그래밍 > WinForm' 카테고리의 다른 글
114. 리스트뷰(ListView)와 트리뷰(TreeView)를 이용해서 간단한 윈도우탐색기 만들기 (0) | 2009.08.28 |
---|---|
113. 트리뷰(TreeView) (0) | 2009.08.28 |
111. PictureBox와 OpenFileDialog를 이용하여 간단한 이미지뷰어(ImageViewer) 만들기 (0) | 2009.08.28 |
110. 체크리스트박스(CheckedListBox) (0) | 2009.08.28 |
109. 창 ( 창 닫기 / 계단식 정렬 / 수평 바둑판 정렬 / 수직 바둑판 정렬 ) (0) | 2009.08.27 |