问题描述
我正在使用C#和Infragistics 15.我有一个带有UltraGrid的WinForm,我想根据内容自动调整窗口的大小.我寻找了这个,然后发现SizeToContent属性.
I'm using C# and Infragistics 15.I have a WinForm with an UltraGrid and I want to auto-ajust the window's size to the content.I looked for this and I found SizeToContent property.
但是我无法在窗口中找到此属性.
But I can not find this property with my window.
FrmCVault是我窗口的名称.
FrmCVault is my window's name.
这是我一开始打开的窗口:
This is my windows when I open it at the beginning :
这是我向下滚动时的窗口,我想删除底部的空白以使其适合内容:
And this is my window when I scroll down, I'd like to delete the blank at the bottom, to make it fit to the content :
推荐答案
您可以将Form
的AutoSize
属性设置为true,并将AutoSizeMode
设置为GrowAndShrink
.
You can Set AutoSize
property of Form
to true and Set AutoSizeMode
to GrowAndShrink
.
设计模式:
运行时间:
您还可以将此解决方案与FlowLayoutPanel
混合,并将其AutoSize
设置为true,将AutoSizeMode
设置为GrownadShrink
.
Also you can Mix this solution with a FlowLayoutPanel
and set its AutoSize
to true and AutoSizeMode
to GrownadShrink
.
如果您需要更紧密的设计,还可能需要设置控件Padding
和Margin
.
Also you may need to set controls Padding
and Margin
if you need more tight design.
根据您的编辑,答案现在有所不同,并且与UltraGrid控件有关.
Based on your edit, the answer is now a bit different and is related to UltraGrid control.
如果您的网格不支持自动调整大小,则可以使用上述说明,同时手动设置网格的高度yourGrid.Height = ((NumebrOfRows+1) * HeightOfRow)
,如果需要则添加其他空格.
If your grid doesn't support auto size, you can use described answer above, while you set the height of grid manually yourGrid.Height = ((NumebrOfRows+1) * HeightOfRow)
and add additional spaces if you nedd.
这篇关于如何自动调整窗口大小以适合其内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!