! 제품 버전을 정확하게 입력해 주세요.
제품 버전이 정확하게 기재되어 있지 않은 경우,
최신 버전을 기준으로 안내 드리므로
더욱 빠르고 명확한 안내를 위해
제품 버전을 정확하게 입력해 주세요!

마우스를 올렸을 때 버튼 색상이 변경되는 사용자정의 버튼 셀 > 지식 쉐어링

본문 바로가기

Spread.NET

지식 쉐어링

WinForms 마우스를 올렸을 때 버튼 색상이 변경되는 사용자정의 버튼 셀

페이지 정보

작성자 GCK써니 작성일 2022-10-19 17:09 조회 895회 댓글 0건

본문

기본 C# WinForms에서 제공하는 Button 컨트롤을 사용하는 경우, Button에 마우스를 가져갔을 때 버튼 색상이 변경됩니다. 이를 통해 해당 버튼 위에 커서가 존재한다는 사실을 알 수 있습니다.

6794f058c8f66e0062948eaa6a02b917_1666166608_8168.gif
 

Spread.NET에서 제공하는 버튼 셀 타입(Button Cell Type)을 활용하시는 경우에도 이와 같이 동작하도록 할 수 있습니다.

첨부된 샘플 코드에서는 buttonCellType을 상속받는 사용자정의 셀 타입 HoverButtonCellType을 정의하고 있습니다.

필요하신 경우, 샘플 코드를 개발에 참고하여주시기 바랍니다.

private void Form1_Load(object sender, EventArgs e)
{
    HoverButtonCellType buttonCt = new HoverButtonCellType();
    fpSpread1.ActiveSheet.Cells[2, 2].CellType = buttonCt;
}

public class HoverButtonCellType : FarPoint.Win.Spread.CellType.ButtonCellType
{
    public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
    {
        if (appearance.MouseOver)
        {
            System.Windows.Forms.VisualStyles.VisualStyleElement element = System.Windows.Forms.VisualStyles.VisualStyleElement.Button.PushButton.Hot;
            if (System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(element))
            {
                FarPoint.Win.FpVisualStyleRenderer vsr = new FarPoint.Win.FpVisualStyleRenderer(element);
                vsr.DrawBackground(g, r);
                return;
            }
        }

        base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
    }
}

6794f058c8f66e0062948eaa6a02b917_1666166975_394.gif
 

  • 페이스북으로 공유
  • 트위터로  공유
  • 링크 복사
  • 카카오톡으로 보내기

댓글목록

등록된 댓글이 없습니다.

메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기

인기글

더보기
  • 인기 게시물이 없습니다.
메시어스 홈페이지를 통해 제품에 대해서 더 자세히 알아 보세요!
홈페이지 바로가기
이메일 : sales-kor@mescius.com | 전화 : 1670-0583 | 경기도 과천시 과천대로 7길 33, 디테크타워 B동 1107호 메시어스(주) 대표자 : 허경명 | 사업자등록번호 : 123-84-00981 | 통신판매업신고번호 : 2013-경기안양-00331 ⓒ 2024 MESCIUS inc. All rights reserved.