* 리스트뷰(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로 변경




--> 출력화면




Posted by holland14
: