如何设置图像索引并填充图像 [英] how to set image index and fill the image

查看:169
本文介绍了如何设置图像索引并填充图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在图片编辑中得到了6张这样的图片





但是当我禁用第2和第4张图像的可见性时,它变空或空白。
我想要的是另一个图像像这样填充空白或图像(不仅仅是第2和第4,可见性在我想要的时候都是假的):



我使用的代码是:

 位图gambr1 =新位图(Properties.Resources。 Add_f,32,32); 
位图gambr2 =新位图(Properties.Resources.Edit_f,32,32);
位图gambr3 =新位图(Properties.Resources.Delete_f,32,32);
位图gambr4 =新位图(Properties.Resources.print,32,32);
Bitmap gambr5 = new Bitmap(Properties.Resources.sheet,32,32);
位图gambr6 =新位图(Properties.Resources.close,32,32);


private void dev12_Load(object sender,EventArgs e)
{
pictureEdit1.Image = gambr1;
pictureEdit2.Image = gambr2;
pictureEdit3.Image = gambr3;
pictureEdit4.Image = gambr4;
pictureEdit5.Image = gambr5;
pictureEdit6.Image = gambr6;

if(pictureEdit2.Visible == false)
{
pictureEdit2.Visible = false;

}
if(pictureEdit4.Visible == false)
{
pictureEdit4.Visible = false;每个位置
}
}

 点a1 =新点(162,10); 
点b1 =新点(233,10);
点c1 =新点(304,10);
点d1 =新点(376,10);
点e1 =新点(447,10);
点f1 =新点(518,10);`


解决方案

你可以使用



另外作为另一种选择,您可以所有图片框添加到 面板。这种方式当你使其中一个看不见时,其他人将填充左边的空间。


I got 6 images like this in picture edit

but when I disable the visibility of 2nd and 4th image it got empty or blank. What I want is the other image fill the empty or image like this (not just 2nd and 4th, visibility false whenever I want):

the code I use is:

Bitmap gambr1 = new Bitmap(Properties.Resources.Add_f, 32, 32);      
Bitmap gambr2 = new Bitmap(Properties.Resources.Edit_f, 32, 32);       
Bitmap gambr3 = new Bitmap(Properties.Resources.Delete_f, 32, 32);        
Bitmap gambr4 = new Bitmap(Properties.Resources.print, 32, 32);      
Bitmap gambr5 = new Bitmap(Properties.Resources.sheet,32,32);        
Bitmap gambr6 = new Bitmap(Properties.Resources.close, 32, 32);        


private void dev12_Load(object sender, EventArgs e)
{
    pictureEdit1.Image = gambr1;
    pictureEdit2.Image = gambr2;
    pictureEdit3.Image = gambr3;
    pictureEdit4.Image = gambr4;
    pictureEdit5.Image = gambr5;
    pictureEdit6.Image = gambr6;

    if ( pictureEdit2.Visible == false)
    {                
        pictureEdit2.Visible = false; 

    }
    if ( pictureEdit4.Visible == false)
    {
        pictureEdit4.Visible = false;          
    }
}

for each location is

Point a1 = new Point(162,10);
Point b1 = new Point(233,10);
Point c1 = new Point(304,10);
Point d1 = new Point(376,10);
Point e1 = new Point(447,10);
Point f1 = new Point(518,10);`

解决方案

You can use a FlowLayoutPanel. This way when a control is invisible, other control shifts and fill the space:

  • Set Padding of FlowLayoutPanel to specify the distance between the container and contents.
  • Set Margin of controls to specify the distance between controls in the FlowLayoutPanel.

In the below example, I set Padding of FlowLayoutPanel to 5 and Margin of all PictureBox controls to 5 and then set Visible of controls to false by click. You see as soon as I make a control invisible, the layout changes:

Also as another option you can Dock all picture boxes to Left in a Panel. This way also when you make one of them invisible, others will fill the space to left.

这篇关于如何设置图像索引并填充图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆