2012-12-05 4 views
14

Windows Forms에서 TableLayoutPanel 사용. SizeType을 AutoSize 및 Percent로 각각 RowStyles 및 ColumnStyles를 사용하고 있습니다. 특정 컨트롤이 배치 된 셀의 절대 높이와 ​​너비를 알아야합니다.Windows Forms에서 TableLayoutPanel 셀의 높이와 너비를 가져옵니다.

TableLayoutPanelCellPosition pos = tableLayoutPanel1.GetCellPosition(button1); 
int height = (int)tableLayoutPanel1.RowStyles[pos.Row].Height; 
int width = (int)tableLayoutPanel1.ColumnStyles[pos.Column].Width; 

위의 높이는 0으로 표시됩니다. RowStyle의 크기 유형은 AutoSize입니다. 마찬가지로 33.33으로 나옵니다. ColumnStyle은 SizeType을 Percent 및 Size = 33.33으로 설정합니다.

셀의 절대 크기를 픽셀 단위로 가져와야합니다.

답변

24

이상한 이유로 Microsoft는 intellisense에서 이러한 기능을 숨기기로 결정했습니다.

이 서면으로 작동합니다 :

TableLayoutPanelCellPosition pos = tableLayoutPanel1.GetCellPosition(button1); 
    int width = tableLayoutPanel1.GetColumnWidths()[pos.Column]; 
    int height = tableLayoutPanel1.GetRowHeights()[pos.Row]; 
+1

나는 인텔리에서 기능을 숨길 수 있었다 감사 몰랐어요! – farukdgn

+0

@farukdgn [BrowsableAttribute 클래스] (https://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute (v = vs.110) .aspx) – LarsTech

+0

함수를 숨기는 지점은 무엇입니까? 그곳에? – farukdgn

관련 문제