David Bird
asked on
Getting Index position of an array from the clickhandler
I have some class code I (scarfed) that allows me to create dynamic control buttons on a form array. The code works. It's code from MS help and I've attached it. I need to be able to remove a button by it's index location when it hits the eventhandler "clickHandler".
I'm just over beginner in programming here so again, be kind please. I've expanded all methods and properties I know how to do in debugger to see what is received as sender and e objects. How do I find the index of the item sent to the handler please?
thanks for any thoughts and help.
dynamicButtons.txt
I'm just over beginner in programming here so again, be kind please. I've expanded all methods and properties I know how to do in debugger to see what is received as sender and e objects. How do I find the index of the item sent to the handler please?
thanks for any thoughts and help.
dynamicButtons.txt
That piece of code works because the original code sets:
aButton.Tag = Me.Count
Uhm, by the way, you may want to add some logic to decrease the .Tag of the remaining buttons (with a .Tag greater than 'n') because the List is getting smaller all the time and the numbers don't match up anymore...
ASKER
I see your point. The tag is equivalent - 1 to the index in the array until I delete an item.
Instead of using the .tag as the reference to the index to remove, is there not a way to search for the button text or some unique value in the button's properties to return its current Index or indexOf?
Or is it smarter to do as you say above and rebuild from the tag on down and/or the array when a row in the array is deleted?
I apologize for the remedial questions, but your response(s) are/have been valuable. I think I must be missing something simple as a method to find or a property sent that has the index value?
thanx
daver
Instead of using the .tag as the reference to the index to remove, is there not a way to search for the button text or some unique value in the button's properties to return its current Index or indexOf?
Or is it smarter to do as you say above and rebuild from the tag on down and/or the array when a row in the array is deleted?
I apologize for the remedial questions, but your response(s) are/have been valuable. I think I must be missing something simple as a method to find or a property sent that has the index value?
thanx
daver
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As much as I would like to continue asking different questions, you've answered my question perfectly. All points awared sir. I'm now "attempting code to adjust locations of the buttons based on the button removed. Based on your responses, I think I can git'r dun! <br /><br />Thank you so kindly for helping me. You da man! <br />daver
Open in new window