Adding controls etc.

drmike

Member
Joined
Mar 3, 2006
Messages
13
Programming Experience
10+
Bear with me on this one.

I want to add 28 rich text boxes to a form in code.
I can do that.

I want to refer to these controls easily - well an array RTB(7,4) of richtextboxes seems good to me especially as they are in a grid 4x7..

BUT I want to handle the click event of each of these 28 boxes

This I believe requires me to use
DIM WITHEVENTS
But you can't do that for an array - or is that not the case

So, I guess I have to use 28 variables but then I'll find it tough to refer to them individually as I wish to by row and column.

Any suggestions at this stage?

To make it more exciting these boxes are in a TableLayoutPanel one per cell. Could I ignore the click event on the rich text box and hope it gets passed up to the conatiner table layout panel?

Perhaps I should be doing this differently!

TIA

Mike
 
You're missing the other method to subscribe to events, use Addhandler keyword to associate an event with an event handler at runtime. For instance:
VB.NET:
Dim newRTB As New RichTextBox
AddHandler newRTB.TextChanged, AddressOf AllRTBs_TextChanged
 
Back
Top