简体   繁体   English

是否可以在 TableLayoutPanel 的边框上添加 PictureBox

[英]Is it possible to add PictureBox on border of TableLayoutPanel

Is there a way to add picturebox in between cells (or on top of borders).有没有办法在单元格之间(或边框顶部)添加图片框。 I've tried using single picturebox on top of the table and bring it to front draw over it and then send it to back, but it is no longer visible at that point.我试过在桌子顶部使用单个图片框并将其放在前面绘制,然后将其发送到后面,但此时不再可见。

这是我正在使用的表,它在运行时改变大小

If you want to customise the appearance of your cells, you can write code in response to the CellPaint event.如果要自定义单元格的外观,可以编写代码来响应CellPaint事件。 In Visual Studio:在 Visual Studio 中:

  1. Click on your layout panel in the form designer在表单设计器中单击您的布局面板
  2. Select the Events section in the Properties panel (the lightning bolt icon)选择“属性”面板中的“ Events部分(闪电图标)
  3. Go down to CellPaint in the Appearance section and double-click on the right-hand side转到外观部分中的CellPaint并双击右侧

Your handler is passed a TableLayoutCellPaintEventArgs argument which provides you with information about which cell needs painting ( Row and Column ), the dimensions ( CellBounds ), and also provides a graphics context in which to do your work ( Graphics ).您的处理程序传递了一个TableLayoutCellPaintEventArgs参数,该参数为您提供有关哪个单元格需要绘制( RowColumn )、尺寸( CellBounds )的信息,还提供了一个图形上下文来完成您的工作( Graphics )。 This lets you fully customise whatever painting you want to do, whether it's images, lines or text, and you can overlay the existing contents.这让您可以完全自定义您想做的任何绘画,无论是图像、线条还是文本,您都可以覆盖现有内容。

There's more information here:这里有更多信息:

https://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.oncellpaint(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.oncellpaint(v=vs.110).aspx

https://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutcellpainteventargs(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutcellpainteventargs(v=vs.110).aspx

You could also add narrow border cells in between your 'room' cells, depending on your graphics requirements, but you're not going to be able to overlap them with their neighbours' contents.您还可以在“房间”单元格之间添加窄边框单元格,具体取决于您的图形要求,但您将无法将它们与其邻居的内容重叠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM