i only want to have horicontal lines in my grid

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
DasGlueck
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Sep 21, 2017 9:22 pm

i only want to have horicontal lines in my grid

Post by DasGlueck » Sat Sep 23, 2017 4:40 pm

hi all,

im using a grid and i only can show all lines or none of them with "EnableGridLines (bool enable=true)"

But i only want horicontal lines visible and the vertical lines should not be visible.

Is there any possibility to make that anyway?

User avatar
doublemax
Moderator
Moderator
Posts: 15512
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: i only want to have horicontal lines in my grid

Post by doublemax » Sat Sep 23, 2017 5:28 pm

I've never tried this myself, but looking through the API there could be a possibility:
Derive your own class from wxGrid, override wxGrid::GetColGridLinePen() and return *wxTRANSPARENT_PEN.

http://docs.wxwidgets.org/trunk/classwx ... 28e63aaa2f
Use the source, Luke!

DasGlueck
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Sep 21, 2017 9:22 pm

Re: i only want to have horicontal lines in my grid

Post by DasGlueck » Sat Sep 23, 2017 6:48 pm

i tryed that examplecode there

Code: Select all

wxPen MidiGrid::GetRowGridLinePen(int row)
{
    if ( row % 12 == 7 )
        return wxPen(*wxBLACK, 1, wxSOLID);
    else
        return GetDefaultGridLinePen();
}
but its not working...sorry. i tryed changing a little bit on it, so it possibly works, but i dont understand it.

could someone - a much more advanced programer as i am - maby try this and show me the solution?
That would be kind :D

but i will of course contiue trying it myself...

thx doublemax

iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 274
Joined: Tue Mar 19, 2013 8:52 pm

Re: i only want to have horicontal lines in my grid

Post by iwbnwif » Sat Sep 23, 2017 8:03 pm

You need to subclass wxGrid (as I think you have done with MidiGrid) and override the function as suggested by Doublemax. In the overridden function, you just need to return a null pen, e.g. midigrid.h could look something like this:

Code: Select all

#include <wx/grid.h> // Base class: wxGrid
#include <wx/pen.h>

class MidiGrid : public wxGrid
{
public:
    MidiGrid(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, 
            const wxSize &size=wxDefaultSize, long style=wxWANTS_CHARS, const wxString &name=wxGridNameStr)
    : wxGrid(parent, id, pos, size, style, name)
    {}
    
    virtual wxPen GetColGridLinePen(int col)
    {
        return wxNullPen;
    }

};
I can confirm the above works on Ubuntu 16.04 and the latest wxWidgets from Github.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.

DasGlueck
Earned a small fee
Earned a small fee
Posts: 15
Joined: Thu Sep 21, 2017 9:22 pm

Re: i only want to have horicontal lines in my grid

Post by DasGlueck » Sun Sep 24, 2017 3:30 pm

I havend used MidiGrid. That was only the examplecode from the link above.

sorry, im still not understanging what you 2 are speaking about. :(
I am no advanced programer.

it will take some time, till i will understand that.

User avatar
doublemax
Moderator
Moderator
Posts: 15512
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: i only want to have horicontal lines in my grid

Post by doublemax » Sun Sep 24, 2017 6:28 pm

You will have to find a C++ tutorial and learn at least the basics about inheritance. It's important to work with wxWidgets.
First one i found using Google: https://www.tutorialspoint.com/cplusplu ... itance.htm
Use the source, Luke!

Post Reply