Results 1 to 7 of 7

Thread: display class member in screen

  1. #1

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    display class member in screen

    i made a class which has speed,symbol (string "*") and location what is the acceptable way to actually display the class symbol property on the screen ?
    the class will be stored in a list<OF T> and will contains hundreds dynamically instances
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  2. #2
    Lively Member
    Join Date
    Apr 2010
    Location
    Australia
    Posts
    71

    Re: display class member in screen

    Depends how you want to display it... ? Bind the list to a listbox, gridview?

  3. #3
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: display class member in screen

    You could override the ToString method so that it returns the Symbol.
    Are you able to provide any more information about what you're trying to achieve as then might be able to come up with a more detailed answer

  4. #4

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: display class member in screen

    ok, for learning purpose i'm trying to create "falling stars" effect, i don't have problem with the logic but i'm not sure of how to display them on the screen, my first idea was to create a dynamic label for each star but it just seem wrong approach from some reason. is it enough details ? if i need to clear anything else please ask.

    thanks
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: display class member in screen

    You could add a Draw method to your class that takes a Graphics object as an argument. In that Draw method you would then call the DrawText method of the Graphics object to draw the Symbol. You might then, for instance, handle the Paint event of a form and do something like this:
    vb.net Code:
    1. For Each item In myList
    2.     item.Draw(e.Graphics)
    3. Next
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Re: display class member in screen

    Humm... to be honest I would personally have done it the way you mentioned but I agree that there probably has to be a better way, although unfortunately I'm not certain how, I would assume it would probably use the GDI+ library, but I'm not familiar with it.
    Sorry I couldn't help

  7. #7

    Thread Starter
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: display class member in screen

    Thanks JM, I never worked with the Graphics class and on screen drawing but i believe this is the way to go i will do some reading now.

    @Satal thanks again for your help, appreciated!
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width