I'm trying to make an application that recognize text character by character so I made a form with a number of panels , I need at least 30, how can I minimize the declaration part of can I make it as OO ??
this is just 5 declarations :(
please heeelp me , I reaaly need help
MyInkoverlay2 =
New InkOverlay(Panel2)MyInkoverlay2.Enabled =
TrueMyInkoverlay3 =
New InkOverlay(Panel3)MyInkoverlay3.Enabled =
TrueMyInkoverlay4 =
New InkOverlay(Panel4)MyInkoverlay4.Enabled =
TrueMyInkoverlay5 =
New InkOverlay(Panel5)MyInkoverlay5.Enabled =
True
Shaikha SaifPosted Apr 20, 2008, 2:39 PM
You saved my life, Thanx man thanks alot and sorry for the trouble
:D
AlanPosted Apr 20, 2008, 12:12 PM
Did you actually place the labels directly on the form or are they inside one (or more) of the panels? If they are then you'll need to index the panel's controls collection rather than the form's collection. For example, if a label was on Panel1:
Dim l As Label = DirectCast(Panel1.Controls("Label" & j.ToString()), Label)
Shaikha SaifPosted Apr 19, 2008, 8:41 PM
thanx alot for your help you saved me, every thing worked fine :D except the label decleration
it gives me a troubleshooting exception!! is there is any other solution for this !!
Thx again and sorry for the trouble
AlanPosted Apr 19, 2008, 5:45 PM
Use AddHandler instead of WithEvents/Handles.
If you're wiring up all the InkOverlay objects to the same handler I'd also set their Name properties in case you need to identify which one has caused the event:
Dim MyInkOverlay(30) As InkOverlay
Dim MyLabel(200) As Label
'....
Sub New()
InitializeComponent()
For j As Integer = 1 To 7
Dim l As Label = DirectCast(Me.Controls("Label" & j.ToString()), Label)
MyLabel(j) = l
MyLabel(j).Text = "Y"
Dim p As Panel = DirectCast(Me.Controls("Panel" & j.ToString()), Panel)
MyInkOverlay(j) = New InkOverlay(p)
MyInkOverlay(j).Name = "MyInkOverlay" & j.ToString()
MyInkOverlay(j).Enabled = True
AddHandler MyInkOverlay(j).Gesture, AddressOf InkOverlayGestureHandler)
Next j
' other code to deal with rest of controls
End Sub
Sub InkOverlayGestureHandler(ByVal sender As Object, ByVal e As InkCollectorGestureEventArgs)
Dim candidate As Gesture
For Each candidate In e.Gestures
MsgBox(candidate.Id + " " + candidate.Confidence)
Next
End Sub
Shaikha SaifPosted Apr 19, 2008, 4:25 PM
Hello, sorry to trouble you all but I'm really new to all this, I'm doing my senior project using vb.net and this is my first time to work with vb.net
So I have to learn it and work with it in a really short time
I'm trying to create an array of labels and connect them to an existing labels in the form as following:
Sub New()
InitializeComponent()
For j As Integer = 1 To 7
Dim p As Panel = DirectCast(Me.Controls("Panel" & (j).ToString()), Panel)
Dim l As Label = DirectCast(Me.Controls("Label" & (j).ToString()), Label)
MyLabel(j) = l
MyInkOverlay(j) = New InkOverlay(p)
MyInkOverlay(j).Enabled = True
MyLabel(j).Text = "Y"
Next j
End Sub
I can write it as :
MyLabel(1) = Label1
MyLabel(2) = Label2
MyLabel(3) = Label3
MyLabel(4) = Label4
....
....
but this wont help me couz I have more than 200 labels in my form
how can I solve this????
Shaikha SaifPosted Apr 19, 2008, 9:53 AM
I tried it and it worked accept for one thing withEvents, 'withEvents' variable cannot be typed as array
///
Dim WithEvents myInkOverlay(30) As InkOverlay
///
Sub InkOvrlayGestureHandler(ByVal sender As Object, ByVal e As InkCollectorGestureEventArgs) Handles MyInkOverlay.Gesture
Dim candidate As Gesture
For Each candidate In e.Gestures
MsgBox(candidate.Id + " " + candidate.Confidence)
Next
End Sub
what can I do to solve this ??
Shaikha SaifPosted Apr 19, 2008, 6:32 AM
Hi there , Thanxs alot man
I ll try it now and hopfully I wish it will work :)
AlanPosted Apr 18, 2008, 12:37 PM
If you're using .NET 2.0 or later, then try this:
Dim
MyInkOverlay(29) As InkOverlay 'or whatever For i As Integer = 0 To 29 Dim p As Panel = DirectCast(Me.Controls("Panel" & (i + 1).ToString()), Panel)MyInkOverlay(i) =
New InkOverlay(p)MyInkOverlay(i).Enabled =
True Next iIf you want to access the array from other methods, then you'll need to declare it at form level rather than as a local variable.