Scrolling list of user controls (and more)

O

Oddball

Hello again,

I have a problem that I can't seem to find any help for. I'm probably not typing the
correct words into goo... *cough*... MSN.

I have created a user control which I would like to use as items in a list. The list would
display as many of these controls as I wish to add, scrolling as it needs to.

I KNOW this functionality exists already in every list you care to mention but I don't
know how to go about making a list display my user control rather than a string as
seems to often be the case.

Anyone help?



------------------------------------

Another unchecked rambeling brought to you by:

Oddball
joshua@bf#N0SP4M#wd.co.uk
 
J

James CC

Dear Oddball,

This might help : (from MSDN)

Typically, Windows handles the task of drawing the items to display in the
ListBox. You can use the DrawMode property and handle the MeasureItem and
DrawItem events to provide the ability to override the automatic drawing
that Windows provides and draw the items yourself. You can use owner-drawn
ListBox controls to display variable-height items, images, or a different
color or font for the text of each item in the list. The HorizontalExtent
property, GetItemHeight, and GetItemRectangle property also provide
assistance for drawing your own items.


Possibly better would be a Listview in Detail mode. I've been using a
control that 'merges' a tree view and a list view
(http://www.codeproject.com/cs/miscctrl/treelistview.asp). That could be a
useful starting point for your needs, though I should warn you that I had to
make quite a few minor fixes before it behaved as I wanted; I hope to post
them back to the site at some point. That uses the Listview to draw the text
and some images, but then draws additional stuff itself, using the
SetIndentation to make space (note - Indentation is based on image width, so
no ImageList, no indentation). It also uses BeforeLabelEdit and
AfterLabelEdit to change the editing Textbox to a Combobox, or similar,
during editing.


Failing that, could you create a scrollable control and handle other
drawing, user input, etc. yourself?


HTH - feels like a single post from me is enough to kill a thread, so sorry
if that happens!!!! ;o)

Now, if I could just get an answer to my scrolling problem ('Scrolling bug
in MDI client windows') I'd be a happy guy...

James
 
O

Oddball

Questions as vague as the one I asked usualy don't get ANY replies, I'm happy with
just one... I'll give it a coat of looking at.

James CC said:
Dear Oddball,

This might help : (from MSDN)

Typically, Windows handles the task of drawing the items to display in the
ListBox. You can use the DrawMode property and handle the MeasureItem and
DrawItem events to provide the ability to override the automatic drawing
that Windows provides and draw the items yourself. You can use owner-drawn
ListBox controls to display variable-height items, images, or a different
color or font for the text of each item in the list. The HorizontalExtent
property, GetItemHeight, and GetItemRectangle property also provide
assistance for drawing your own items.


Possibly better would be a Listview in Detail mode. I've been using a
control that 'merges' a tree view and a list view
(http://www.codeproject.com/cs/miscctrl/treelistview.asp). That could be a
useful starting point for your needs, though I should warn you that I had to
make quite a few minor fixes before it behaved as I wanted; I hope to post
them back to the site at some point. That uses the Listview to draw the text
and some images, but then draws additional stuff itself, using the
SetIndentation to make space (note - Indentation is based on image width, so
no ImageList, no indentation). It also uses BeforeLabelEdit and
AfterLabelEdit to change the editing Textbox to a Combobox, or similar,
during editing.


Failing that, could you create a scrollable control and handle other
drawing, user input, etc. yourself?


HTH - feels like a single post from me is enough to kill a thread, so sorry
if that happens!!!! ;o)

Now, if I could just get an answer to my scrolling problem ('Scrolling bug
in MDI client windows') I'd be a happy guy...

James


------------------------------------

Another unchecked rambeling brought to you by:

Oddball
joshua@bf#N0SP4M#wd.co.uk
 
J

JamesCC

Dear Oddball,

For the TreeListView, the author catches windows messages to know when to
paint, etc. You could no doubt do the same.

By the way, whats a 'coat of looking at'??

Either way, you now have two replies....

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top