0

目前我有一个名为 tChart 的带有 tChart 控件的表单:..

Private Sub txtChart1_Click(sender As System.Object, e As System.EventArgs) Handles txtChart1.Click


TChart1.Series.Clear()

Dim series1 As New Steema.TeeChart.Chart

Dim FirstLabel = New Label()
FirstLabel.Name = "FirstLabel.Name"
FirstLabel.Text = " FirstLabel.Text"

Dim SecondLabel = New System.Windows.Forms.Label()
Dim GridBand = New Steema.TeeChart.Tools.GridBand()

'Main bar 1
Dim BarSeries1 = New Steema.TeeChart.Styles.Bar()
BarSeries1.Brush.Color = System.Drawing.Color.FromArgb(192, 255, 48)
BarSeries1.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked
BarSeries1.Pen.Color = Color.FromArgb(48, 255, 192)
BarSeries1.Title = "barSeries1"
BarSeries1.XValues.DataMember = "X"
BarSeries1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending
BarSeries1.YValues.DataMember = "Bar"

BarSeries1.Add({123, 123, 123, 123, 123})

TChart1.Series.Add(BarSeries1)


'Main bar 2
Dim BarSeries2 = New Steema.TeeChart.Styles.Bar()
BarSeries2.Brush.Color = System.Drawing.Color.FromArgb(48, 255, 192)
BarSeries2.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked
BarSeries2.Pen.Color = Color.FromArgb(48, 255, 192)
BarSeries2.Title = "barSeries2"
BarSeries2.XValues.DataMember = "X"
BarSeries2.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending
BarSeries2.YValues.DataMember = "Bar"

BarSeries2.Add({123, 123, 123, 123, 123})

TChart1.Series.Add(BarSeries2)


TChart1.Aspect.SmoothingMode = Drawing2D.SmoothingMode.HighQuality


End Sub

...在同一个表单类中,我有这个事件处理程序...

Private Sub TChart1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TChart1.MouseDown
mouseX.Text = e.X
mouseY.Text = e.Y

If TChart1.Series.Count > 0 Then

Dim CollectionOfBars As New List(Of String)

For idxSeries As Integer = 0 To TChart1.Series.Count - 1
Dim srs As Steema.TeeChart.Styles.Bar = TChart1.Series(idxSeries)

If srs.BarBounds.Contains(e.X, e.Y) Then
CollectionOfBars.Add(srs.TitleOrName)
End If

Next

txtCollisions.Text = Join(CollectionOfBars.ToArray, ", ")
End If

End Sub

...但它的作用只适用于最后一堆酒吧。我需要适用于所有酒吧的东西。

请帮忙。

4

2 回答 2

0

您应该尝试使用 Clicked 方法:

If srs.Clicked(e.X, e.Y) <> -1 Then
CollectionOfBars.Add(srs.TitleOrName)
End If

而不是您使用的代码:

If srs.BarBounds.Contains(e.X, e.Y) Then
CollectionOfBars.Add(srs.TitleOrName)
End If

它也可能更适合使用 ClickSeries 事件来完成这项工作。如果这没有帮助,请不要犹豫,让我知道。

于 2012-08-29T15:12:27.507 回答
0
Private Sub tctChartBar_Click(Sender As Object, srsBarSeriesClicked As Styles.Series, ValueIndex As Integer, e As System.Windows.Forms.MouseEventArgs) Handles tctScrollableChart.ClickSeries
    Dim strMethodAddress As String = strClassAddress & "Private Sub Bar_Click(Sender As Object, srsBarSeriesClicked As Styles.Series, ValueIndex As Integer, e As System.Windows.Forms.MouseEventArgs) Handles GetChartComponent.ClickSeries"
    Try
        Dim CAAGCanvasConversionBreakdownCriteria As clsCriteria = ctaCriteriaSetting.Copy
        CAAGCanvasConversionBreakdownCriteria.SetWeekNum(srsBarSeriesClicked(ValueIndex).Label)
        frmCAAGCanvasConversionBreakdown.RemoteLaunch(CAAGCanvasConversionBreakdownCriteria, GetSelectedCanvassGroupID)

    Catch ex As Exception
        If blnLoudExceptions Then MsgBox("General Exception Caught in Method: " & strMethodAddress)
    End Try
End Sub
于 2013-04-18T12:39:32.067 回答