Click here to Skip to main content
15,917,731 members
Home / Discussions / C#
   

C#

 
AnswerRe: using nonstatic function in thread Pin
mikker_12312-Mar-07 19:43
mikker_12312-Mar-07 19:43 
AnswerRe: using nonstatic function in thread Pin
Russell Jones12-Mar-07 22:52
Russell Jones12-Mar-07 22:52 
QuestionHow do you change the scrollbar position of a WebBrowser control? [modified] Pin
ThisIsMyUserName212-Mar-07 17:55
ThisIsMyUserName212-Mar-07 17:55 
AnswerRe: How do you change the scrollbar position of a WebBrowser control? Pin
ThisIsMyUserName212-Mar-07 23:46
ThisIsMyUserName212-Mar-07 23:46 
QuestionDisplaying Custom Collection Control Contents Pin
andymo212-Mar-07 17:37
andymo212-Mar-07 17:37 
AnswerRe: Displaying Custom Collection Control Contents Pin
mike montagne12-Mar-07 20:33
mike montagne12-Mar-07 20:33 
GeneralRe: Displaying Custom Collection Control Contents Pin
andymo213-Mar-07 2:21
andymo213-Mar-07 2:21 
GeneralRe: Displaying Custom Collection Control Contents Pin
mike montagne13-Mar-07 6:38
mike montagne13-Mar-07 6:38 
Alright, first of all, I think you're making your job bigger than it has to be with the Covers class. It looks to me like you can use a generic list<t> for what you're doing there. This may save you casting as well. Always use generics if they fit your processing concept, because type safety eliminates casting, which results in economy and speed. The only time I don't use generics is when I have an exceptional circumstance which generics cannot conveniently/appropriately handle.

It is not clear from what you've said so far that your concept for accomplishing your goals is sufficiently refined. Are you embedding your collection/list into an outer composite class which will handle your add method? My initial thinking would be to do so; and I would most likely use that class to handle the basic drawing surface. This would also allow you to hide all the internal members you don't want your clients exposed to. The appropriate base class for your project may be Control. You only need to move up the tree for further behavior if you can best take advantage of (or require) prebuilt features such as scrolling provided by a higher, existent class.

This outer class needs to handle adding and drawing by calling into your list. If you need to assign your images to a picture class which can be selected (or which eliminate having to write specialized code to detect object specific events), you need to pick the class on merits decided by the facts it does more of the things already for you than other classes -- without providing excessive functionality that bloats its footprint.

You may have a basic conceptual problem with Parent assignment (next to last line). What you need to understand is your *display* class (PictureBox? or whatever) has to be parented by your display surface (root Control or Panel for instance). You are making your collection item parented by a UserControl instance, but there is nothing here that tells me you have made your collection item a class which can display an image, and you haven't shown any way that an image is assigned to the collection item class, either.

You need to design a basic process to perform these tasks, and generally such a process must go something like this (envision having to manually do what your code has to do, and that will spell out the process to you):

Your base control probably will need an Add method which inserts or appends a new member in your internalized list/collection. You may also provide susupend and resume methods which allow you to add multiple list members and only draw once at the conclusion of mass member propagations.

The add method assigns an image to the list member object. If that object displays your image for you, then your drawing method decides the position of the object and adds it to the controls array of your root object to set Parent. This in effect draws the object (because internalized drawing methods of the base class do this for you). You probably will not want to try to invoke drawing by calling invalidate.

If on the other hand you choose simply to maintain images in the list and draw them directly to the surface (faster and more efficient), then your Add method draws the image to the surface instead of adding an object to the Controls array.

Incidentally, even when you are double buffering, you do not necessarily have to trigger drawing by calling Invalidate() -- and it may be undesirable to rely on Invalidate(). The IDE sometimes ignores calls to Invalidate(), as it does with other calls such as OnEnabledChanged()/OnSystemColorsChanged(), and this of course can lead to frustrating and costly development issues if you rely on Invalidate().

If you assign your image to the background image of an object however (dimensioned and configured to draw only the image), this *will* trigger Invalidate() under all conditions -- so this is perhaps a more robust approach.

So get your process assigning images to members and drawing them. These vitals are missing from your example.
GeneralRe: Displaying Custom Collection Control Contents Pin
andymo214-Mar-07 10:41
andymo214-Mar-07 10:41 
GeneralRe: Displaying Custom Collection Control Contents Pin
mike montagne14-Mar-07 12:41
mike montagne14-Mar-07 12:41 
Questioncomputing the numeric value of 2 textbox without triggering with a button? (Windows Application) Pin
icesha12-Mar-07 16:13
icesha12-Mar-07 16:13 
AnswerRe: computing the numeric value of 2 textbox without triggering with a button? (Windows Application) Pin
rah_sin12-Mar-07 18:24
professionalrah_sin12-Mar-07 18:24 
GeneralRe: computing the numeric value of 2 textbox without triggering with a button? (Windows Application) Pin
PS@Codeproj12-Mar-07 19:44
PS@Codeproj12-Mar-07 19:44 
GeneralRe: computing the numeric value of 2 textbox without triggering with a button? (Windows Application) Pin
rah_sin12-Mar-07 20:06
professionalrah_sin12-Mar-07 20:06 
QuestionAnomalous behavior implementing the Dispose pattern? Pin
mike montagne12-Mar-07 15:49
mike montagne12-Mar-07 15:49 
QuestionQuestion on an error message Pin
JMOdom12-Mar-07 15:36
JMOdom12-Mar-07 15:36 
AnswerRe: Question on an error message Pin
rah_sin12-Mar-07 18:10
professionalrah_sin12-Mar-07 18:10 
QuestionCompressing files to multiple .zip's Pin
Ollie198612-Mar-07 13:16
Ollie198612-Mar-07 13:16 
AnswerRe: Compressing files to multiple .zip's Pin
Ollie198612-Mar-07 21:39
Ollie198612-Mar-07 21:39 
GeneralRe: Compressing files to multiple .zip's Pin
sherifffruitfly13-Mar-07 14:53
sherifffruitfly13-Mar-07 14:53 
QuestionHow to compare struct Pin
LiamD12-Mar-07 12:36
LiamD12-Mar-07 12:36 
AnswerRe: How to compare struct Pin
Dawid Mazuruk12-Mar-07 13:00
Dawid Mazuruk12-Mar-07 13:00 
AnswerRe: How to compare struct Pin
tgrt12-Mar-07 13:30
tgrt12-Mar-07 13:30 
AnswerRe: How to compare struct Pin
mike montagne12-Mar-07 14:22
mike montagne12-Mar-07 14:22 
QuestionDataGrid Selection Pin
mrarunks12-Mar-07 11:57
mrarunks12-Mar-07 11:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.