wxGrid

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
felix
Earned a small fee
Earned a small fee
Posts: 17
Joined: Sat Nov 05, 2011 10:46 am

wxGrid

Post by felix »

Hello,

I am new to wxWidgets and ran into several issues using wxGrid.

1) according to the wxWiki, i can disable the edit box for the cell being edited only by deriving a custom class from wxGrid and overriding DrawCellHighlight:
If you want to change the way the "Current Cell"-highlight is drawn, simply derive a class from wxGrid and override
void DrawCellHighlight(wxDC& dc, const wxGridCellAttr *attr);
Leave the method body empty to disable cell highlighting. -- chris, advised by Scott on the wx forum.
Is there really no easier way?

2) How can i react to changes a user makes in cells?
From php i know
wx.grid.EVT_GRID_CELL_CHANGE - Triggered when the user changes the data in a cell via an editor.
but this doesnt seem to be available.
I also tried to catch keystrokes in general, but it wouldnt work like this:

Code: Select all

	
const int ID_TEST = 101;
wxGrid* grd = new wxGrid( this,
		ID_TEST,
		wxPoint( 0, 0 ),
		wxSize( 400, 300 ) );

grd->GetEventHandler()->Connect(ID_TEST, wxEVT_KEY_DOWN, wxCommandEventHandler(MyWindow::Test));
It compiles fine, but no keystrokes are processed.


3)
If i have multiple cells selected, how can i get the cell that is active, ie being edited?

4)
if i want to draw directly on a wxGrid control:

Code: Select all

void MyWindow::OnPaint(wxPaintEvent &event)
{
	wxPaintDC dc(myGrid);
	dc.DrawLine(50, 60, 190, 60);
}
But the line is not visible... :(
It works fine on a plain window.

f.
asadilan
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Jul 27, 2010 10:42 pm

Re: wxGrid

Post by asadilan »

1. SetReadOnly will prevent user from editing.
2.EVT_GRID_CELL_CHANGE its available.
EVT_GRID_CMD_CELL_CHANGE

3. GetSelectedCells would give you grid coord.
4. not sure what you are trying to do, but the grid should be drawn automatically without u needing to draw in onpaint function.
maybe you can further explain.
Post Reply