locked
Datagridview - Chart RRS feed

  • Question

  • Hello My name is Ozan Bayrak

    I have a Datagridview with some data in it.

    I have a code that can make a chart when you click on the Column "Groep"

    But when I click on the other Columns you will get the same chart.

    How can I make it that it only makes a chart when i only click on the column"Groep" not the other columns.

    // Code Example //

    Private Sub DataGridView1_ColumnHeaderMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.ColumnHeaderMouseClick

            If e.RowIndex - 1 Then

                With Chart1.Series(0)
                    .Name = "Groep"
                    .Font = New Font("Arial", 8, FontStyle.Italic)
                    .Color = Color.Red
                    .BackSecondaryColor = Color.Red
                    .IsValueShownAsLabel = True
                    .LabelBackColor = Color.Red
                    .LabelForeColor = Color.Gold
                    .Points.DataBindY(dtTest.DefaultView, "Groep")
                    .Font = New Font(Chart1.Font, FontStyle.Bold)

                End With

            End If

            Chart1.Series(0).ChartType = SeriesChartType.Line

        End Sub

    // End Code Example. //

    Monday, December 17, 2012 8:12 AM

Answers

  • the DataGridViewCellMouseEventArgs class also has a ColumnIndex property that you can use to test which ColumnHeader was clicked

    thanks for any help

    • Marked as answer by Ozan Bayrak Monday, December 17, 2012 2:29 PM
    Monday, December 17, 2012 8:50 AM
  • ColumnIndex is an integer

    thanks for any help

    • Marked as answer by Ozan Bayrak Monday, December 17, 2012 3:45 PM
    Monday, December 17, 2012 9:58 AM

All replies

  • the DataGridViewCellMouseEventArgs class also has a ColumnIndex property that you can use to test which ColumnHeader was clicked

    thanks for any help

    • Marked as answer by Ozan Bayrak Monday, December 17, 2012 2:29 PM
    Monday, December 17, 2012 8:50 AM
  • the DataGridViewCellMouseEventArgs class also has a ColumnIndex property that you can use to test which ColumnHeader was clicked

    thanks for any help

    Monday, December 17, 2012 8:50 AM
  • Hello Paul,

    I did tryed that before but it gives me a error "The Column Groep convert to double is invalid."

    i writed like this.

    // Code ///

    If e.ColumnIndex = "Groep" Then

    // Code make Chart.

    End if

    // Code End //

    Am i doing it wrong ?

    Monday, December 17, 2012 9:09 AM
  • ColumnIndex is an integer

    thanks for any help

    • Marked as answer by Ozan Bayrak Monday, December 17, 2012 3:45 PM
    Monday, December 17, 2012 9:58 AM