Clicking on Cells
Details
Date:10/23/2012 10:13:15 AM
Product:ActiveGanttVBN Gantt Chart / Scheduler Component
Framework:.Net Framework 4.0 / Visual Studio 2010
Version:2.9.3.0
User's Development Environment:Visual Basic .Net 2010
Subject:Click Event
Question

Could you provide an example on how to work with the click event on a Row and getting the value of any cell in the selected Row.

Answer

Answer:

In a new Windows Form, include an ActiveGanttVBN control named ActiveGanttVBNCtl1, and then paste the following code:


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim oRow As AGVBN.clsRow
        ActiveGanttVBNCtl1.Columns.Add("Column1", "Column1", 125)
        ActiveGanttVBNCtl1.Columns.Add("Column2", "Column2", 125)
        ActiveGanttVBNCtl1.Columns.Add("Column3", "Column3", 125)
        oRow = ActiveGanttVBNCtl1.Rows.Add("Row1", "", False, True, "")
        oRow.Cells.Item("1").Text = "1"
        oRow.Cells.Item("2").Text = "2"
        oRow.Cells.Item("3").Text = "3"
        oRow = ActiveGanttVBNCtl1.Rows.Add("Row2", "", False, True, "")
        oRow.Cells.Item("1").Text = "4"
        oRow.Cells.Item("2").Text = "5"
        oRow.Cells.Item("3").Text = "6"
        oRow = ActiveGanttVBNCtl1.Rows.Add("Row3", "", False, True, "")
        oRow.Cells.Item("1").Text = "7"
        oRow.Cells.Item("2").Text = "8"
        oRow.Cells.Item("3").Text = "9"
    End Sub


    Private Sub ActiveGanttVBNCtl1_ControlClick(ByVal sender As Object, ByVal e As AGVBN.MouseEventArgs) Handles ActiveGanttVBNCtl1.ControlClick
        If e.EventTarget = AGVBN.E_EVENTTARGET.EVT_ROW Or e.EventTarget = AGVBN.E_EVENTTARGET.EVT_SELECTEDROW Then
            Dim oRow As AGVBN.clsRow
            Dim oCell As AGVBN.clsCell
            oRow = ActiveGanttVBNCtl1.Rows.Item(ActiveGanttVBNCtl1.MathLib.GetRowIndexByPosition(e.Y).ToString())
            oCell = oRow.Cells.Item(ActiveGanttVBNCtl1.MathLib.GetCellIndexByPosition(e.X).ToString())
            MessageBox.Show("You clicked on: " & oCell.Text, "ControlClick")
        End If
    End Sub

Whenever you click on a cell a dialog box will pop up:

 

All trademarks are property of their respective holders, and are only used to directly describe the products and services being provided. Their use in no way indicates any relationship or endorsement between The Source Code Store LLC and the holders of said trademarks.