bammurdo's Profile User Rating: -----

Reputation: 3 Apprentice
Group:
Contributors
Active Posts:
62 (0.04 per day)
Joined:
03-October 09
Profile Views:
2,591
Last Active:
User is offline Jul 25 2012 09:25 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
50

Latest Visitors

Icon   bammurdo has not set their status

Posts I've Made

  1. In Topic: Easy way to add objects to a 2D Array?

    Posted 25 Jul 2012

    View PostRobin19, on 23 July 2012 - 01:47 PM, said:

    It works just fine for me. Do all of your buttons begin with the name "point"? It has to be exact, something called "Point0000" does not start with "point". Are your buttons on a different control from the form itself?

    HA, now I feel silly
    Thanks a lot man :)
  2. In Topic: Easy way to add objects to a 2D Array?

    Posted 21 Jul 2012

    View PostRobin19, on 19 July 2012 - 12:19 PM, said:

    Something I forget to do all the time. LINQ generates an IEnumerable. Either the 3 methods need to return IEnumerable(Of Button) instead of List(Of Button) or the returns need to change to <variable>.ToList().

    @trevster344: There is only one error checking that happens. The only error that it throws is if you input an invalid row or column. An example would be calling GetButtonsByLocation(-10, 999) would generate an error. This isn't any different than calling my2dArray[-10, 999] would generate an error.

    Thanks, that worked out :)
    However, during testing - this line seems to be letting it down:
    Dim gridButtons = From b In buttons
                      Where b.Name.StartsWith("point")
    
    

    in the GetGridButtons function.

    the line above it:
    Dim buttons = From b In Controls
                  Where (TypeOf (B)/> Is Button)
                  Select CType(b, Button)
    
    

    Works, and I can see the list of buttons, but GridButtons always returns with nothing.
    Any ideas where I'm going wrong?
  3. In Topic: Easy way to add objects to a 2D Array?

    Posted 19 Jul 2012

    View PostRobin19, on 19 July 2012 - 11:14 AM, said:

    Then they are already in a list. Each form has a property called Controls that contains all controls displayed. That is what part of the auto generated code does, it adds the drag and dropped controls to this property.

    I would try to get away from having a separate list. Try adding the following methods. I used LINQ to find the buttons (assuming your displayed naming convention). (Note, I'm usually in C# so this code might need syntax tweaking)
     removed code for neatness
    
    


    Thanks Robin, this looks like what I want, but i keep running into this Invalid cast exception:
    Unable to cast object of type 'WhereEnumerableIterator`1[System.Windows.Forms.Button]' to type 'System.Collections.Generic.List`1[System.Windows.Forms.Button]'.

    The call I used: GetButtonsByLocation(0, 1).Text = "Testing :)"
  4. In Topic: Easy way to add objects to a 2D Array?

    Posted 19 Jul 2012

    View PostRobin19, on 19 July 2012 - 10:41 AM, said:

    View Postbammurdo, on 19 July 2012 - 08:42 AM, said:

    Basically, I have a grid of existing objects in this sort of fashion:...<snip>

    Your grid of existing objects, what are the objects? Are they controls on a form?

    Yeah, controls on the form - sorry if that wasn't clear.
    Edit: They're buttons - if that changes anything
  5. In Topic: Easy way to add objects to a 2D Array?

    Posted 19 Jul 2012

    View Posttrevster344, on 19 July 2012 - 10:21 AM, said:

    Using simple math, a list, and a box object I created which contained a name and a point, I created this.


    deleted code.


    This produces a grid of box objects, the box objects contain a name, when clicked they display their name, and their point which they just so happen to encapsulate.....


    Good luck to you partner, maybe someone else can help you accomplish what your task is, but I surely will not. Maybe you misunderstood the part of this forum where you need to show the code you've tried.. it appears to me as though you've done nothing but shoot us down and then sit back and wait for more suggestions.. that's not how this works. You show us code, we give you suggestions, you either take them or you try something else and keep going. We don't do code hand outs.


    I showed you exactly what I've done - which works - and i'm looking to see if there is a faster way than typing them all out.

My Information

Member Title:
D.I.C Head
Age:
19 years old
Birthday:
May 16, 1994
Gender:
Location:
here :)
Programming Languages:
HTML, XHTML, CSS, PhP, JavaScript, JQuery, VB

Contact Information

E-mail:
Private