첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ SplitterControl 클래스 : SplitPosition 속성을 사용해 컨트롤 숨기기

------------------------------------------------------------------------------------------------------------------------


TestProject.zip


MainForm.cs

 

 

using System;

using System.Windows.Forms;

 

using DevExpress.XtraBars;

using DevExpress.XtraEditors;

 

namespace TestProject

{

    /// <summary>

    /// 메인 폼

    /// </summary>

    public partial class MainForm : XtraForm

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Field

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region Field

 

        /// <summary>

        /// 타이머

        /// </summary>

        private Timer timer;

 

        /// <summary>

        /// 축소 여부

        /// </summary>

        private bool collapsing;

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainForm()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainForm()

        {

            InitializeComponent();

 

            #region 타이머를 설정한다.

 

            this.timer = new Timer();

 

            this.timer.Interval = 10;

 

            #endregion

            #region 이벤트를 설정한다.

 

            this.timer.Tick += timer_Tick;

 

            this.showListButtonItem.ItemClick += showListButtonItem_ItemClick;

 

            #endregion

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region 타이머 틱 처리하기 - timer_Tick(sender, e)

 

        /// <summary>

        /// 타이머 틱 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void timer_Tick(object sender, EventArgs e)

        {

            int splitPosition = this.splitterControl.SplitPosition;

 

            if(this.collapsing)

            {

                if(splitPosition > 30)

                {

                    splitPosition -= 10;

 

                    if(splitPosition < 30)

                    {

                        splitPosition = 30;

                    }

 

                    this.splitterControl.SplitPosition = splitPosition;

                }

                else

                {

                    this.timer.Stop();

                }

            }

            else

            {

                if(splitPosition < 300)

                {

                    splitPosition += 10;

 

                    if(splitPosition > 300)

                    {

                        splitPosition = 300;

                    }

 

                    this.splitterControl.SplitPosition = splitPosition;

                }

                else

                {

                    this.timer.Stop();

                }

            }

 

            if(!this.timer.Enabled)

            {

                if(this.collapsing)

                {

                    this.showListButtonItem.Caption = "목록 표시";

                }

                else

                {

                    this.showListButtonItem.Caption = "목록 숨김";

                }

 

                this.showListButtonItem.Enabled = true;

            }

        }

 

        #endregion

        #region 목록 표시 버튼 항목 클릭시 처리하기 - showListButtonItem_ItemClick(sender, e)

 

        /// <summary>

        /// 목록 표시 버튼 항목 클릭시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void showListButtonItem_ItemClick(object sender, ItemClickEventArgs e)

        {

            this.collapsing = !this.collapsing;

 

            this.showListButtonItem.Enabled = false;

 

            this.timer.Start();

        }

 

        #endregion

    }

}

 

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요