Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
UltraExpandableGroupBox - Size
posted

Hi,

I have added a UltraExpandableGroupBox inside a TableLayoutPanel row and trying to add a TableLayoutPanel to the UltraExpandableGroupBox dynamically. Here I need to set the UltraExpandableGroupBox size depends upon it's child control(here it is a TableLayoutPanel)

Code:

private void Load(List<StudentInfo> students)
{

var tableLayoutPanel = new TableLayoutPanel();
tableLayoutPanel.ColumnCount = 3;
tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100F));
tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 250F));
tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100F));
tableLayoutPanel.Dock = DockStyle.Fill;
tableLayoutPanel.Location = new Point(0, 0);
tableLayoutPanel.Margin = new Padding(4);
tableLayoutPanel.Padding = new Padding(4);
tableLayoutPanel.Name = "studentsTable";
tableLayoutPanel.RowCount = 1;
tableLayoutPanel.RowStyles.Add(new RowStyle());

int rowNumber = 0;

for(int i=0; i <= students.Count; i++)

{

var rowIndex = rowNumber > 0 ? AddTableRow() : rowNumber; // here adding a new row to the table

Control firstName = RichText(students[i].fName);
_demogViewControls.HistoricalAppointments.Controls.Add(firstName);
_demogViewControls.HistoricalAppointments.SetCellPosition(firstName, new TableLayoutPanelCellPosition(0, rowIndex));

Control lastName = RichText(students[i].lName);
_demogViewControls.HistoricalAppointments.Controls.Add(lastName);
_demogViewControls.HistoricalAppointments.SetCellPosition(lastName, new TableLayoutPanelCellPosition(1, rowIndex));

Control studentAddress = RichText(students[i].sAddress);
_demogViewControls.HistoricalAppointments.Controls.Add(studentAddress);
_demogViewControls.HistoricalAppointments.SetCellPosition(studentAddress, new TableLayoutPanelCellPosition(2, rowIndex));

rowNumber++;

}

studentsGroupBox.Panel.Controls.Add(tableLayoutPanel); // studentsGroupBox is a UltraExpandableGroupBox, added in UI (___.Designer.cs)

studentsGroupBox.Height = tableLayoutPanel.Height;

}

It will bee great if anyone can help me on this regard.

Thanks in advance,

Top Replies