Custom Scrolling in C1TileControl
The Tiles in C1TileControl are scrollable by default. When the user presses “Home/End” key in TileControl's tiles, it navigate through first/last tile directly. However, the flexible architecture of the control makes it easy to customize this scrolling to a great extent. Consider an example, where the Form in a Windows Application contains a number of tiles such that the user can scroll them using the horizontal scrollbar. But, what if the user wishes to scroll the control to the first tile beginning with whichever letter is pressed through keyboard? One just needs to follow the below provided steps in order to accomplish this requirement:
- Use the KeyUp event of C1TileControl and iterate through all the tiles in that particular group.
- If the Name/Text of the Tile starts with the key pressed by the user, scroll to the Tile using the ScrollToTile method as follows:
private void c1TileControl1_KeyUp(object sender, KeyEventArgs e)
{
for(int i = 0; i<= c1TileControl1.Groups[0].Tiles.Count - 1; i++)
{
if (c1TileControl1.Groups[0].Tiles[i].Name.StartsWith(e.KeyData.ToString()))
{
c1TileControl1.ScrollToTile(c1TileControl1.Groups[0].Tiles[i], true);
}
}
}