Cell Operations

Posted by: Luis.Alvarez on 6 June 2018, 12:52 pm EST

  • Posted 6 June 2018, 12:52 pm EST

    Hello,

    I'm in the process of migrating a VB 6.0 fpSpread application to VB 2017 GCSpread.NET WPF. The old application uses _BlockSelected, _MouseUp and _RightClick event handlers to perform different function on a cell or a selection of cells. I first implemented a _MouseUp and a _MouseRightButtonDown event handlers but was not able to get the selected cell row and column information. I then tried _CellClick and while the handler provides me with the selected cell row and column information it only works for left click events. Right click events are ignored. Here is the basic functionality that I'm trying to implement:

    1. _RightClick. When the user right clicks on a cell the application adds an "X" to the cell where the right click occurred.
    2. _MouseUp. When the user releases the mouse button the application performs the following:
    a. If it is the right button the handler exits since the logic was handled by the _RightClick event.
    b. If a range of cells is selected (left click and drag the mouse across selecting a group of cells) the handler exits since the logic is performed by the _BlocksSelected handler.
    c. If it is the left button the application then displays a color coded "X" on the cell.
    3. _BlockSelection. The application, upon releasing the left mouse button add color coded "X" in all the selected cells.
    Can you help me with this?
    Thanks,
    Luis
  • Replied 7 June 2018, 6:48 am EST

    Hello,

    I figured out how to get the left hand mouse click to provide the information I need. The only issue I still have is that I can not select a cell or get the _CellClick event to trigger when using the right mouse button.

    Thanks,
    Luis

  • Marked as Answer

    Replied 7 June 2018, 8:24 am EST

    Hi Luis,

    You can use MouseDown event to know the active cell. Here is the code to do that:

    gcSpreadSheet1.CanCellOverflow = true;
    void gcSpread1_MouseDown(object sender, MouseButtonEventArgs e)
    {
    HitTestInformation info = gcSpreadSheet1.HitTest(e.GetPosition(gcSpreadSheet1).X, e.GetPosition(gcSpreadSheet1).Y);
    if (info.HitTestType == HitTestType.Corner)
    gcSpreadSheet1.Sheets [0].SetText (0,0,"Click SheetCorner of control");
    if (info.HeaderInfo != null)
    {
    if (info.HeaderInfo.InColumnResize)
    gcSpreadSheet1.Sheets[0].SetText(0, 0, "Column" + info.HeaderInfo.Column.ToString() + " is resizing");
    else if (info.HeaderInfo.InRowResize)
    gcSpreadSheet1.Sheets[0].SetText(0, 0, "Row" + info.HeaderInfo.Row.ToString() + " is resizing");
    }
    }



    http://help.grapecity.com/spread/SpreadWPF/webframe.html#GrapeCity.WPF.SpreadSheet.UI~GrapeCity.Windows.SpreadSheet.UI.HitTestType.html

    Also in MouseDown event I don't think you make a cell active. You should rather use MouseUp event or MouseClick event with SetActiveCell() method.

    Thanks,
    Deepak Sharma
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels