1

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

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

serhio
  • 28,010
  • 62
  • 221
  • 374

2 Answers2

2

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

More details could be consulted here

Community
  • 1
  • 1
serhio
  • 28,010
  • 62
  • 221
  • 374
1

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.

Community
  • 1
  • 1
LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • we use the Infragistics UltraCombo foe 2 columns comboboxes... So the problem is just to integrate the UltraCombo to the StatusStrip... – serhio Sep 27 '11 at 09:16