Re: PictureBoxes and Charting
- From: "sen" <sen@xxxxxxxxxxxxx>
- Date: Tue, 25 Mar 2008 08:04:28 +0100
"Webbiz" <noreply@xxxxxxx> skrev i en meddelelse
news:e1Qe3sijIHA.1272@xxxxxxxxxxxxxxxxxxxxxxx
I'm currently using a single PictureBox to contain my price charts.You need a pictureBox control array
It appears that the best way to add indicators to the bottom of my price
charts is to actually add another PictureBox below the chart PictureBox
for each indicator I want to add, so each indicator is within its own
PictureBox and can be resized independently, etc.
And if that is the case, I suppose that I must keep track of all the
PictureBox height values, so the total of them all equals 100% of the
Forms ScaleHeight. If I raise the height of one, I must decrease the
height of one or more of the others, etc.
If this is correct so far...
Since I do not know how many indicators one might add below the chart
PictureBox that always exists, I imagine that I should not pre-create
these PictureBoxes during dev-time, but create them when needed during
run-time, and then destroy them when removed by the user.
Would this be the purpose of using the New command to create these
PictureBoxes as needed? And what is the procedure for destroying them when
no longer needed?
I know these are basic questions, but I've not done this before, creating
objects during run-time. I've always just dragged the control onto the
form during dev-time and made them visible when needed, knowing how many I
would need to begin with. In this case, I have no idea how many the user
will want to add.
Thanks.
Webbiz
Read below, you can find this text in
Books on Line under "Control Arrays"
Copy my routine down below into a form1.
Put on 2 command buttons. set the captions
to load and unload. Put on a pictureBox and set
its index property to 0. This will create a
Picture1 pictureBox controlArray.
You just have to keep account with the
Index (IndxPic variable).
senn
You can add and remove controls in a control
array at run time using the Load and Unload
statements. However, the control to be added
must be an element of an existing control
array. You must have created a control at
design time with the Index property set,
in most cases, to 0. Then, at run time,
use this syntax:
Load object(index%)
Unload object(index%)
Argument Description
object Name of the control to add to or
delete from the control array.
index% The control's index value in
the array.
When you load a new element of a control
array, most of the property settings are
copied from the lowest existing element
in the array - in this example, the
element with the 0 index value. The
Visible, Index, and TabIndex property
settings are not automatically copied
to new elements of a control array,
so to make the newly added control
visible, you must set its Visible
property to True.
Note
Visual Basic generates an error
if you attempt to use the Load statement
with an index number already in use in
the array.
Important
You can use the Unload statement to
remove any control created with Load.
However, you cannot use Unload to
remove controls created at design time,
regardless of whether or not they are
part of a control array.
Option Explicit
Dim IndxPic As Integer
Private Sub Command1_Click()
IndxPic = IndxPic + 1
Load Picture1(IndxPic)
Picture1(IndxPic).Visible = True
Picture1(IndxPic).Left = 0
Picture1(IndxPic).Top = 0
Picture1(IndxPic).Left = Picture1(IndxPic - 1).Left
Picture1(IndxPic).Top = Picture1(IndxPic - 1).Top +
Picture1_(IndxPic).Height
End Sub
Private Sub Command2_Click()
Unload Picture1(IndxPic)
IndxPic = IndxPic - 1
End Sub
.
- References:
- PictureBoxes and Charting
- From: Webbiz
- PictureBoxes and Charting
- Prev by Date: Re: What is disskussions?
- Next by Date: Re: PictureBoxes and Charting
- Previous by thread: Thanks Sen, Christy, Larry :) NM
- Next by thread: Re: PictureBoxes and Charting
- Index(es):
Loading