Апр 23, 2014 - Уроки C#, Уроки Visual Basic.NET Один комментарий
Красивые панельки (Panel)
Думаю можно маленько приукрасить панельки, вы согласны?
Если да, то добавляйте на форму две панели.
На VB.NET:
Imports System.Drawing.Drawing2D Public Class Form1 Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint e.Graphics.SmoothingMode = SmoothingMode.AntiAlias e.Graphics.FillRectangle(Brushes.WhiteSmoke, New Rectangle(0, 0, sender.width, sender.height)) e.Graphics.DrawRectangle(Pens.Gainsboro, New Rectangle(0, 0, sender.width - 1, sender.height - 1)) e.Graphics.DrawRectangle(Pens.White, New Rectangle(1, 1, sender.width - 3, sender.height - 3)) End Sub Private Sub Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint e.Graphics.SmoothingMode = SmoothingMode.AntiAlias e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(235, 235, 235)), New Rectangle(2, 0, sender.Width, sender.Height)) e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(249, 249, 249)), New Rectangle(1, 0, sender.Width - 3, sender.Height - 4)) e.Graphics.DrawRectangle(New Pen(Color.FromArgb(214, 214, 214)), 0, 0, sender.Width - 2, sender.Height - 3) End Sub End Class
На C#:
using System.Drawing.Drawing2D; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void panel2_Paint(object sender, PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(235,235,235)), new Rectangle(2, 0, panel2.Width, panel2.Height)); e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(249,249,249)), new Rectangle(1, 0, panel2.Width - 3, panel2.Height-4)); e.Graphics.DrawRectangle(new Pen(Color.FromArgb(214, 214, 214)), new Rectangle(0, 0, panel2.Width - 2, panel2.Height - 3)); } private void panel1_Paint(object sender, PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.FillRectangle(Brushes.WhiteSmoke, new Rectangle(0, 0, panel1.Width, panel1.Height)); e.Graphics.DrawRectangle(new Pen(Color.Gainsboro), new Rectangle(0, 0, panel1.Width - 1, panel1.Height - 1)); e.Graphics.DrawRectangle(new Pen(Color.White), new Rectangle(1, 1, panel1.Width - 3, panel1.Height - 3)); } } }
Похожие записи:
Метки: Panel, графика, Красивые панельки, создаем красивую панель, элемент Panel
Евгений
Просмотров: 8 498
Запись опубликована в 17:19
не подскажите где можно почитать про использование свойства Tag у панелек?