Windows Develop Bookmark and Share   
 index > Windows Forms General > I set DrawMode as OwnerDrawFixed, but can't get the horizontal scroll bar any more. (ListBox)
 

I set DrawMode as OwnerDrawFixed, but can't get the horizontal scroll bar any more. (ListBox)

I just override the below method,

protected override void OnDrawItem(DrawItemEventArgs e)

{

base.OnDrawItem(e);

this.DrawMode = DrawMode.OwnerDrawFixed;

e.DrawBackground();

// Define the default color of the brush as black.

SolidBrush foreBrush = new SolidBrush(e.ForeColor);

// Draw the current item text based on the current Font and the custom brush settings.

e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, foreBrush, e.Bounds, StringFormat.GenericDefault);

}

But even the string width exceeded the width of ListBox, there was no horizontal scroll bar.

How to solve the problem?

THx in advance.

Lunar Fifth  Monday, October 16, 2006 8:40 AM
Don't forget to implement the ListBox.MeasureItem event.
nobugz  Saturday, October 28, 2006 3:51 PM
Try fiddling with the HorizontalExtent property perhaps? Not sure exaclty how it works, but maybe you could measure the string drawn and use the width value to set the HorizontalExtent...
Noldorin  Wednesday, October 25, 2006 2:31 PM
Don't forget to implement the ListBox.MeasureItem event.
nobugz  Saturday, October 28, 2006 3:51 PM

You can use google to search for other answers

Custom Search

More Threads

• Adding and removing the tabpages in C#
• Drag and drop from explorer works differently under debug (platform 64 bit Vista)
• windows form visual basic
• FolderBrowserDialog - Can't select network computers
• A little confusion about typecasting.
• How to maintain Japanese encoding in Strings/Paths?
• Open an MDI child since another mdi child
• how to draw a rectangle background when the informatio is display using c#
• Refrence files
• Owner drawn CheckedListBox control