locked
Word Search solve method RRS feed

  • Question

  • I am working on a solve method for a Word Search C# program.  The program puts words a grid in a random order and populates the remaining spaces with random characters.  I am trying to "solve" the puzzle by changing the word characters to red and leaving the random characters black.  I can change all the characters, but not just the ones I want. Any suggestions?

    Thank you...
    Sunday, February 8, 2009 1:50 AM

Answers

  • How are you creating your "grid" of letters? 
    One control, or is each tile/letter a separate control? 

    How big is the grid? 

    Windows.Forms cannot handle too many controls, but they can handle dozens or even a few hundred small blank panels.  Let each panel display a background image, an image of a letter.  Change the image to change text colors.  You  could add the images to your Properties.Resources.  A 40x40 grid will load up in a flash.  Images would allow simple animated sequences.

    Or, you could put a label onto each panel.  Make each one a custom control inheriting from Panel.  Change the text and font color at runtime to create your effects.  Or Leave the labels alone and simply change the backcolor of the panels. 

    Or, you could combine both techniques and just get really creative.........

    Rudedog   =8^D




    Mark the best replies as answers. "Fooling computers since 1971."


    EDIT:  HINT:  Add the tiles programmatically.  The Form Designer will get the way and goof things up over the long haul.  But, you can drop a single tile onto a form with the Designer, and then look at the Designer.cs file to see what is needed to add a control programmatically.  Create a separate collection, or a dictionary, of all of the tiles that you add to the form.  It will prove handy.
    Sunday, February 8, 2009 1:01 PM
    Moderator

All replies

  • How are you creating your "grid" of letters? 
    One control, or is each tile/letter a separate control? 

    How big is the grid? 

    Windows.Forms cannot handle too many controls, but they can handle dozens or even a few hundred small blank panels.  Let each panel display a background image, an image of a letter.  Change the image to change text colors.  You  could add the images to your Properties.Resources.  A 40x40 grid will load up in a flash.  Images would allow simple animated sequences.

    Or, you could put a label onto each panel.  Make each one a custom control inheriting from Panel.  Change the text and font color at runtime to create your effects.  Or Leave the labels alone and simply change the backcolor of the panels. 

    Or, you could combine both techniques and just get really creative.........

    Rudedog   =8^D




    Mark the best replies as answers. "Fooling computers since 1971."


    EDIT:  HINT:  Add the tiles programmatically.  The Form Designer will get the way and goof things up over the long haul.  But, you can drop a single tile onto a form with the Designer, and then look at the Designer.cs file to see what is needed to add a control programmatically.  Create a separate collection, or a dictionary, of all of the tiles that you add to the form.  It will prove handy.
    Sunday, February 8, 2009 1:01 PM
    Moderator
  • Rudedog,

    Thanks for the reply.

    The grid is just one control.  First I was using the form window to display a 2D array of characters, and have since changed to a picture box so I can include a word list on the side.  I ended up using a Boolean 2D array with the value set to true if the character is part of the word list.  Clicking the Solve button now changes the answers to a bold red font.  All I need to do now is find a way to "circle" the words.  Is this possible with a single control or would separate controls be needed?  I am still new to this and stumbling along as I go.

    Thanks,

    Lakewobegon
    Wednesday, March 4, 2009 3:30 AM
  •  My mind is already biased towards separate controls for each letter.  Not sure what your "grid is just one control" actually is though.  A PictureBox? 

    "Is this possible to do with a single control?"  Most anything within reason is possible to do.  What should be most important is development time and proper functionality.  My programming style would make a single control solution not as attractive as the solution I had suggested above. 

    Whatever you decide to do, go for simplicity.  That usually means creating an analogy of the real thing inside of your computer.  Sometimes the actual nature of real objects is elusive.  Elusive because the answers are frequently so simple and obvious that they can be right in front of your face staring back, waiting for you to recognize it.

    I would be inclined to think that every location or letter on the grid is nearly identical to every other letter.  In fact location and letter are actually two separate concepts.  Any letter can be at any location.  Two different concepts, two different classes.

    Rudedog  =8^D
    Mark the best replies as answers. "Fooling computers since 1971."
    Wednesday, March 4, 2009 2:44 PM
    Moderator