Giter Club home page Giter Club logo

Comments (2)

jgmdev avatar jgmdev commented on May 29, 2024

Checking the wxWidgets header files seems that wxEVT_GRID_CMD_RANGE_SELECT doesn't exists so the correct one to use is wxEVT_GRID_RANGE_SELECT.

I'm not really sure what you want to do but the range select event is when you want to select the values of various rows at the same time. If you want to select the values of some cells for the current row wxEVT_GRID_SELECT_CELL would be a better choice. Also remember that every function which is connected to an event, will receive an event object of the type of that event. Here I did some small fix to the code you shared to make it work and the selected function receives a wxGridEvent object. You can use var_dump($event) to know which event type is being passed.

By the way, is interesting how you are doing the coding :) you are making use of the library in a structured form more than its OO nature, which is good for small test scripts.

<?php
$main = new wxFrame(null, wxID_TOP, "Title" );

$vbox = new wxBoxSizer(wxVERTICAL);

$grid = new wxGrid($main, wxID_ANY );
$grid->Connect(wxEVT_GRID_SELECT_CELL, array(wxID_TOP, "selected") );
$grid->CreateGrid(3, 3);
$grid->SetCellValue(0, 0, "x");
$grid->SetCellValue(0, 1, "y");
$grid->SetCellValue(0, 2, "z");
$grid->SetCellValue(1, 0, "a");
$grid->SetCellValue(1, 1, "b");
$grid->SetCellValue(1, 2, "c");
$grid->SetCellValue(2, 0, "d");
$grid->SetCellValue(2, 1, "e");
$grid->SetCellValue(2, 2, "f");
$grid->Layout();

$vbox->Add($grid, 0, wxALL, 10 );

$selectedA = new wxTextCtrl($main, wxID_ANY );
$vbox->Add($selectedA, 0, wxALL, 10 );

$selectedC = new wxTextCtrl($main, wxID_ANY );
$vbox->Add($selectedC, 0, wxALL, 10 );

$main->SetSizer($vbox);

$main->Show();

wxEntry();

function OnInit() { return 1; }
function OnExit() { return 1; }

function selected($event)
{   
    global $grid, $selectedA, $selectedC;
    $selrow = $event->GetRow();

    $grid->SelectRow($selrow);

    $selectedA->SetValue($grid->GetCellValue($selrow, 0) );
    $selectedC->SetValue($grid->GetCellValue($selrow, 2) );
}
?>

from wxphp.

davekimble2 avatar davekimble2 commented on May 29, 2024

Also remember that every function which is connected to an event, will receive an event object of the type of that event.

That's news to me - that must be what "void handlerFuncName(wxGridRangeSelectEvent& event)" means!
Many thanks.

from wxphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.