Rendering Forms Controls within rows of a listbox
-
Hi, I am speccing an application that requires a listbox control whose rows contain other (output-only) controls; namely a static image, a drawn image (i.e. can't be in a file), a progress bar and some plain text. Something like:
#pic# < Image > [---Bar-- ] Text
All in one row, with different controls simultaneously visible in other rows. I know it is possible to OwnerDraw all this from scratch. Is it possible to build it up using existing other controls, esp. the progressbar control. Any thoughts? Ruth -
Hi, I am speccing an application that requires a listbox control whose rows contain other (output-only) controls; namely a static image, a drawn image (i.e. can't be in a file), a progress bar and some plain text. Something like:
#pic# < Image > [---Bar-- ] Text
All in one row, with different controls simultaneously visible in other rows. I know it is possible to OwnerDraw all this from scratch. Is it possible to build it up using existing other controls, esp. the progressbar control. Any thoughts? RuthHi Ruth, You could use the DataGrid control and create custom a DataGridColumnStyle for you progress bar and other controls. This MSDN article has some introductory information and takes you through some sample code. I recommend that you read part 1 before moving onto part 2 so that you understand the architecture of the DataGrid. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/datagridcolumnstyle1.asp
-
Hi Ruth, You could use the DataGrid control and create custom a DataGridColumnStyle for you progress bar and other controls. This MSDN article has some introductory information and takes you through some sample code. I recommend that you read part 1 before moving onto part 2 so that you understand the architecture of the DataGrid. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/datagridcolumnstyle1.asp
Thanks for the link: it was useful. Do you suggest the DataGrid because you know the ListBox cannott do what I want?
-
Thanks for the link: it was useful. Do you suggest the DataGrid because you know the ListBox cannott do what I want?
I am glad that you found the link useful. I certainly found it to be an interesting article. I have seen the ListBox control customised but not to the extent that you require. The DataGrid control was built with extensibility in mind whereas the ListBox control was always meant to be a simple control for simple situations. Perhaps it is possible to do what you are asking with the ListBox control but I am not sure how you would go about it. I would personally stick with a method that is well documented and that is easier to find help for if you run into problems.