Question

Is there a way to add a custom control to a StatusStrip Control?

Say, I need a multicolumn Combobox in the status bar...

Was it helpful?

Solution

As the modest Hans Passant mentioned, the solution was using the ToolStripControlHost and the ToolStripDesignerAvailability attribute.

More details could be consulted here

OTHER TIPS

Easiest way is to do the drawing yourself using a ToolStripComboBox and then place that control in your StatusStrip. The ToolStripComboBox is different from the normal ComboBox because it derives from the ToolStripControlHost.

Dim comboStatus As New ToolStripComboBox
With DirectCast(comboStatus.Control, ComboBox)
  .DrawMode = DrawMode.OwnerDrawFixed
  AddHandler .DrawItem, AddressOf comboStatus_DrawItem
End With
StatusStrip1.Items.Add(comboStatus)

And then you use the DrawItem event:

Private Sub comboStatus_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs)
  Dim comboStatus As ComboBox = sender
  e.DrawBackground()

  If e.Index > -1 Then
    //Do you drawing.
  End If
End Sub

See ComboBox.DrawItem Event for the drawing details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top