Hi,
I have a number of different sub UserControl forms that inherit from an AbstractUserControl. Each of the sub UserControls contains a TableLayoutPanel and a DataGridView.
Depending on which sub UserControl is loaded, I want to resize that controls DataGridView.
I was thinking Events would be the best way to do this?
In the AbstractUserControl I have added..
public event EventHandler<Events.UserControlResizeEventArgs.ResizeControlEventArgs> ResizeControlEvent;
this.ResizeControlEvent +=
new EventHandler<Events.UserControlResizeEventArgs.ResizeControlEventArgs>(this.AbstractUserControl.UserControl_Resize);I also have a Resize Form event (AbstractUserControl_Resize) that should call UserControl_Resize() event.
However AbstractUserControl_Resize event does not get hit. Any ideas?
private void AbstractUserControl_Resize(object sender, EventArgs e)
{
if (null != this.ResizeControlEvent)
{
Events.UserControlResizeEventArgs.ResizeControlEventArgs
resizeControlEventArgs = new Events.UserControlResizeEventArgs.ResizeControlEventArgs(this.ui_ProcessDashboardDataGridView, this.uiTableLayoutPanel);
this.ResizeControlEvent(this, resizeControlEventArgs);
}
}private void UserControl_Resize(object sender, EventArgs e)
{
if (this.ui_ProcessDashboardDataGridView.Rows.Count != 0)
{
this.uiTableLayoutPanel.RowStyles[1].SizeType = SizeType.Absolute;
int height = 0;
foreach (DataGridViewRow row in this.ui_ProcessDashboardDataGridView.Rows)
{
height += row.Height;
}
height += this.ui_ProcessDashboardDataGridView.ColumnHeadersHeight;
this.uiTableLayoutPanel.RowStyles[1].Height = height + 30;
this.ui_ProcessDashboardDataGridView.ClientSize = new Size(
this.ui_ProcessDashboardDataGridView.Width,
height);
}
}Thanks!