I have a list of countries to be displayed inside the table layout panel(one col x many rows). A combobox filter exists to filter the different continents and based on the filtered continent name, the list of countries are made visible and hidden inside the table view. However, when you scroll the scroller up and down and then you apply a combo-box filter to a different continent name, the scroller doesn't scroll up to the top. The scroller should return to the first visible country control/component inside the table panel layout.
Has anyone has experienced this issue before. The code looks something like this. Any help will be much appreciated. I have been trying different options, nothing seems to have any effect on the scroller.
<pre>
{
....
if (scrollDirection == ScrollDirection.Up)
{
Control usercontrol = GetFirstVisibleCountryUC();
if (usercontrol != null)
{
tableLayoutPanelCountries.ScrollControlIntoView(usercontrol);
tableLayoutPanelCountries.Invalidate(); //Refresh, Update have tried different options
}
}
.....
}
private Control GetFirstVisibleCountryUC()
{
foreach (CountryUC uc in this.tableLayoutPanelCountries.Controls)
{
if (uc.Visible)
{
return uc;
}
}
return null;
}
</pre>
The scroller should return to the first visible country control/component inside the table panel layout.
If that's exactly what you need, then the following should do the job
tableLayoutPanelCountries.AutoScrollPosition = new Point(0, 0);