Articles in this section
Category / Section

How to assign the currently selected GroupBarItem to the WinForms GroupBar’s Tag property?

1 min read

GroupBarItemSelected event

You could do so by handling the GroupBar’s GroupBarItemSelected event. Within this event handler, index into the GroupBarItems Collection using the GroupBar's SelectedItem property value to get the currently selected GroupBarItem, and then assign it to the GroupBar’s Tag property. The following code sample shows how this can be done:

C#

private void groupBar1_GroupBarItemSelected(object sender, System.EventArgs e)
{
   // Index into the GroupBarItems Collection using GroupBar.SelectedItem
   // as the index value, and assign it to GroupBar’s Tag property
    this.groupBar1.Tag = this.groupBar1.GroupBarItems[this.groupBar1.SelectedItem];
}

 

VB

Private Sub groupBar1_GroupBarItemSelected(ByVal sender As Object, ByVal e As System.EventArgs)
   ' Index into the GroupBarItems Collection using GroupBar.SelectedItem
   ' as the index value, and assign it to GroupBar’s Tag property
      Me.groupBar1.Tag = Me.groupBar1.GroupBarItems(Me.groupBar1.SelectedItem)
End Sub

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied