WinForms 마우스를 올렸을 때 버튼 색상이 변경되는 사용자정의 버튼 셀
추천0 비추천 0
페이지 정보
작성자 GCK써니 작성일 2022-10-19 17:09 조회 895회 댓글 0건본문
관련링크
기본 C# WinForms에서 제공하는 Button 컨트롤을 사용하는 경우, Button에 마우스를 가져갔을 때 버튼 색상이 변경됩니다. 이를 통해 해당 버튼 위에 커서가 존재한다는 사실을 알 수 있습니다.
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); } }
댓글목록
등록된 댓글이 없습니다.