Obtaining Index of Rectangle Array
Obtaining Index of Rectangle Array
Hello,
I'm using VS2008 VB.Net
I can create multiple Rectangles within the Click event of a push button.
I can also capture a Click event from a mouse click on any of the newly created Rectangles.
My question is , how do I determine the Index of each Rectangle, assuming I have created them as members of an array?
Thanks !!
I'm using VS2008 VB.Net
I can create multiple Rectangles within the Click event of a push button.
I can also capture a Click event from a mouse click on any of the newly created Rectangles.
My question is , how do I determine the Index of each Rectangle, assuming I have created them as members of an array?
Thanks !!
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Obtaining Index of Rectangle Array
Hi tirby,
We would need more detailed information about your application. Could you please attach a simple example project we can run "as-is" to reproduce the problem here so that we can provide an accurate answer?
Thanks in advance.
We would need more detailed information about your application. Could you please attach a simple example project we can run "as-is" to reproduce the problem here so that we can provide an accurate answer?
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Obtaining Index of Rectangle Array
After entering new text in the Textbox, click the "Enter" button.
This will create a rectangle rect(x). Move it to the middle of the graph.
Now change the text in the Textbox and hit the "Enter" button again. A new rectangle wil be created rect(x+1).
Move it to an emplty spot on the graph.
Now monitoring the right label (Label2), click on one of the retangles.
I need to be able to detect in a code module named "rectangle_Click" an index of the retangle that has been clicked.
This will create a rectangle rect(x). Move it to the middle of the graph.
Now change the text in the Textbox and hit the "Enter" button again. A new rectangle wil be created rect(x+1).
Move it to an emplty spot on the graph.
Now monitoring the right label (Label2), click on one of the retangles.
I need to be able to detect in a code module named "rectangle_Click" an index of the retangle that has been clicked.
- Attachments
-
- ChartTest.Zip
- (8.88 KiB) Downloaded 676 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Obtaining Index of Rectangle Array
Hi tirby,
Thanks for the project but the "My Project" folder is missing so I can not build the application. Could you please send the project with this folder too?
Thanks in advance.
Thanks for the project but the "My Project" folder is missing so I can not build the application. Could you please send the project with this folder too?
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Obtaining Index of Rectangle Array
Sorry about that,
Here is a Zip file with the files that belong in MyProject!
Thanks
Here is a Zip file with the files that belong in MyProject!
Thanks
- Attachments
-
- MyProject.Zip
- (6.12 KiB) Downloaded 694 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Obtaining Index of Rectangle Array
Hi tirby,
Thanks for the files. You just need to do some little modifications in rectangle_Click:
Thanks for the files. You just need to do some little modifications in rectangle_Click:
Code: Select all
Private Sub rectangle_Click(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim rect As Steema.TeeChart.Tools.RectangleTool = CType(sender, Steema.TeeChart.Tools.RectangleTool)
Dim c As Integer = TChart1.Tools.IndexOf(rect)
Dim b As String = "Rectangle " + (c + 1).ToString()
Label2.Text = b
End Sub
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Obtaining Index of Rectangle Array
Thanks Narcis,
I have modified the routine as such:
Now, if you create 2 new rectangles, then right-mouse click on the 1st rectangle (Index 0) created to delete it , the second retangle (Index 1) seems to shift down to Index 0.
However, it won't delete.
Also, is there a background color option available for the rectangles?
Thanks
I have modified the routine as such:
Code: Select all
Private Sub rectangle_Click(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim recti As Steema.TeeChart.Tools.RectangleTool = CType(sender, Steema.TeeChart.Tools.RectangleTool)
Dim c As Integer = TChart1.Tools.IndexOf(recti)
Dim b As String = ""
Select Case e.Button
Case 1048576 'Left
b = Str(c)
Case 4194304 'Middle
b = "Middle"
Case 2097152 'Right
rect(c).Dispose()
End Select
Label2.Text = b
End Sub
However, it won't delete.
Also, is there a background color option available for the rectangles?
Thanks
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Obtaining Index of Rectangle Array
Hi tirby,
Also, what about using this?
or
Thanks in advance.
I'm not able to reproduce this here using latest TeeChart for .NET v3 release available at the client area, which is build 3.5.3700.30574/5. Which is the exact TeeChart version you are using? Does last version solves the problems at your end? If it doesn't could you please post the exact steps we should follow to reproduce the problem here?Now, if you create 2 new rectangles, then right-mouse click on the 1st rectangle (Index 0) created to delete it , the second retangle (Index 1) seems to shift down to Index 0.
However, it won't delete.
Also, what about using this?
Code: Select all
TChart1.Tools.Remove(recti)
Code: Select all
recti.Dispose()
Yes, you can do this:Also, is there a background color option available for the rectangles?
Code: Select all
rect(rectcount).Shape.Brush.Color = Color.Red
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Obtaining Index of Rectangle Array
I was using version 3.5.3371.26406
I upgraded to version 3.5.3700.30575
This made no difference, the problem still persists.
Using: TChart1.Tools.Remove(recti) works in this instance.
The fact that the Index shifts seems inconsequential at this point.
However, below is a series of steps to re-produce the effect.
1. Create 2 new rectangles.
2. Left-Mouse click on the first retangle, Note the value shown in label2. (displays "0")
3. Left-Mouse click the second retangle, again note the value displayed in Label2. (displays "1")
4. Right-mouse click on the 1st rectangle (Index 0) created to delete it.
5. Left-Mouse click on the remaining rectangle (This should be the second retangle created) The value displayed in Label2 now display's "0"
I upgraded to version 3.5.3700.30575
This made no difference, the problem still persists.
Using: TChart1.Tools.Remove(recti) works in this instance.
The fact that the Index shifts seems inconsequential at this point.
However, below is a series of steps to re-produce the effect.
1. Create 2 new rectangles.
2. Left-Mouse click on the first retangle, Note the value shown in label2. (displays "0")
3. Left-Mouse click the second retangle, again note the value displayed in Label2. (displays "1")
4. Right-mouse click on the 1st rectangle (Index 0) created to delete it.
5. Left-Mouse click on the remaining rectangle (This should be the second retangle created) The value displayed in Label2 now display's "0"
- Attachments
-
- Chart1.Zip
- (15.81 KiB) Downloaded 707 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Obtaining Index of Rectangle Array
Hi tirby,
Yes, of course, that's because when removing one tool in TChart's tool collection remaining tools indexes are relocated they will always go from 0 to Tools.Count-1. So, if you have to tools (0 and 1) and remove tool with index=0 then tool with index=1 will be re-indexed to 0. If you want to get something which remains through tools re-indexing you can display Tag property, for example:
Yes, of course, that's because when removing one tool in TChart's tool collection remaining tools indexes are relocated they will always go from 0 to Tools.Count-1. So, if you have to tools (0 and 1) and remove tool with index=0 then tool with index=1 will be re-indexed to 0. If you want to get something which remains through tools re-indexing you can display Tag property, for example:
Code: Select all
Private Sub rectangle_Click(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim recti As Steema.TeeChart.Tools.RectangleTool = CType(sender, Steema.TeeChart.Tools.RectangleTool)
'Dim c As Integer = TChart1.Tools.IndexOf(recti)
Dim b As String = ""
Select Case e.Button
Case MouseButtons.Left
b = recti.Tag 'Str(c)
Case MouseButtons.Middle
b = "Middle"
recti.Shape.Brush.Color = Color.Red
Case MouseButtons.Right
'rect(c).Dispose()
TChart1.Tools.Remove(recti)
End Select
Label2.Text = b
End Sub
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Obtaining Index of Rectangle Array
Thanks for all your help Narcis.
One last question:
How do I change the color of the text in the retangle tool?
Thanks!
One last question:
How do I change the color of the text in the retangle tool?
Thanks!
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Obtaining Index of Rectangle Array
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |