如第一張圖片所示,我找不到有關如何繪制幾個點(用于拆分分隔符滑塊)的任何資訊。
我試圖畫這個:

現在,我的自定義控制元件代碼正在繪制一條帶陰影的直線
public class CustomPaintSplitter : SplitContainer {
...
protected override void OnPaint(PaintEventArgs pe)
{
Graphics g = pe.Graphics;
Rectangle r = ClientRectangle;
g.FillRectangle(new SolidBrush(BackColor), r);
if (Orientation == Orientation.Horizontal)
{
SplitterWidth = 9;
int recWidth = SplitterRectangle.Width / 3;
Rectangle split_rect = new(SplitterRectangle.X recWidth, SplitterRectangle.Y, SplitterRectangle.Width - recWidth, SplitterRectangle.Height);
int x = split_rect.X;
int y = split_rect.Y 3;
g.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x, y 2);
g.DrawLine(new Pen(SystemColors.ControlLightLight), x, y, x recWidth, y);
g.DrawLine(new Pen(SystemColors.ControlDark), x, y 2, x recWidth, y 2);
g.DrawLine(new Pen(SystemColors.ControlDark), x recWidth, y, x recWidth, y 2);
}
// Calling the base class OnPaint
base.OnPaint(pe);
}
}

如何做到這一點?我在互聯網上嘗試了不同的 Point[] 方法,但沒有一個能接近我想要實作的目標。
即使是指定繪制的“點”數量的引數也是一個加號。
任何幫助表示贊賞!
uj5u.com熱心網友回復:
我只是在面板上繪制它,但您可以以同樣的方式使用它。
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Brush b = new SolidBrush(Color.Gray);
e.Graphics.FillEllipse(b, new Rectangle(10, 5, 5, 5));
e.Graphics.FillEllipse(b, new Rectangle(20, 5, 5, 5));
e.Graphics.FillEllipse(b, new Rectangle(30, 5, 5, 5));
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/509988.html
標籤:C#表格
