Reputation: 3 Apprentice
- Active Posts:
- 62 (0.04 per day)
- 03-October 09
- Profile Views:
- Last Active:
- Jul 25 2012 09:25 AM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Who Cares
- Dream Kudos:
Posts I've Made
Posted 25 Jul 2012
Posted 21 Jul 2012Something 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?
Posted 19 Jul 2012Then 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 "
Posted 19 Jul 2012
Yeah, controls on the form - sorry if that wasn't clear.
Edit: They're buttons - if that changes anything
Posted 19 Jul 2012
Using simple math, a list, and a box object I created which contained a name and a point, I created this.
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.
- Member Title:
- D.I.C Head
- 19 years old
- May 16, 1994
- here :)
- Programming Languages: