I have an PictureBox and an Image in PictureBox1.Image
property.
How do I place a border around the Image?
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I have an PictureBox and an Image in PictureBox1.Image
property.
How do I place a border around the Image?
This has always been what I use for that:
改变边界颜色,从电影盒控制涂料活动手里引来:
private void pictureBox1_Paint_1(object sender, PaintEventArgs e)
{
ControlPaint.DrawBorder(e.Graphics, pictureBox1.ClientRectangle, Color.Red, ButtonBorderStyle.Solid);
}
为了积极改变边界色,例如从一次浮标活动中改变边界,我利用照片箱的塔格财产储存颜色,并调整图像箱的Click事件,从那里取回。 例如:
if (pictureBox1.Tag == null) { pictureBox1.Tag = Color.Red; } //Sets a default color
ControlPaint.DrawBorder(e.Graphics, pictureBox1.ClientRectangle, (Color)pictureBox1.Tag, ButtonBorderStyle.Solid);
因此,图片箱Click事件就是如此:
private void pictureBox1_Click(object sender, EventArgs e)
{
if ((Color)pictureBox1.Tag == Color.Red) { pictureBox1.Tag = Color.Blue; }
else {pictureBox1.Tag = Color.Red; }
pictureBox1.Refresh();
}
页: 1 提炼;,一开始,就不用忘记打上pictureBox1.Refresh(
。 欢乐!
You can t set the size and color of the border of a PictureBox
.
But you can do a little trick to accomplish that.
Set your image to the BackgroundImage
property.
Set the BackgroundImageLayout
to Center
.
Change the BackColor
property to the color you want the border to be.
Now resize the PictureBox
enough to show the back color, which will now visually act like a border.
您还可以使用<条码>,以完成最后一步。
希望会有所帮助。
你们能够创造自己的形象 盒式从System.Windows.Forms.PictureBox
继承,并优先于PictureBox
OnPaint
方法,从此使用System.Forms.ControlPaint
。 采用提款法和在贵方通过 系统。 Windows.Forms.PaintEventArgs from the OnPaint methods.
与此类似;
using System.Windows.Forms;
using System.Drawing;
public class CustomPictureBox : PictureBox
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, Color.Red, ButtonBorderStyle.Solid);
}
}
这只是一个迅速的例子(未经测试),使你开始,令我感到担忧的是,我可能更彻底。
为实现这一目标,我使用了一个有背景形象的纽芬兰语,并建立了平整式房地产。
What is the use of default keyword in C#? Is it introduced in C# 3.0 ?
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...
I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...
Since I cannot order my dictionary, what is the best way of going about taking key value pairs and also maintaing an index?
Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...