public void CollapseExpandSpacer(ChannelListChannel channelListChannel) { int spacerIndex = channelListChannels.IndexOf(channelListChannel); for (int i = spacerIndex + 1; i < channelListChannels.Count; i++) { // Check if the channelListChannel is a spacer if (channelListChannels[i].channel.Name.ToLower().Contains("[spacer]")) { // Stop the loop here break; } else { // Hide/Show the control channelListChannels[i].Visible = !channelListChannels[i].Visible; } } }
private void SetInitialValues() { for (int i = 0; i < Channels.Count; i++) { // Set some initial values bool isSpacer = false; bool isActive = false; // Check if the channel is a spacer if (Channels[i].Name.ToLower().Contains("[spacer]")) { isSpacer = true; } // Check if the channel is the active channel if (Channels[i].Name == ActiveChannel.Name) { isActive = true; } // Create a custom user control for the channel ChannelListChannel channelListChannel = new ChannelListChannel(Channels[i], this, mainForm, isSpacer, isActive); // Check if the channel is a spacer, but not the first channel if (isSpacer) { channelListChannel.Cursor = Cursors.Hand; if (i > 0) { // Add some margin to the top of the channelListChannel channelListChannel.Margin = new Padding(0, 30, 0, 0); } } // Add it to the list for easy access channelListChannels.Add(channelListChannel); // Add it to the tabel layout control tableLayoutPanelChannelList.Controls.Add(channelListChannel); tableLayoutPanelChannelList.SetRow(channelListChannel, i); } }