how to draw lines around 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
hu0118
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 23, 2017 3:23 pm

how to draw lines around wxgrid

Post by hu0118 »

hi
i use wxgrid in my project,but it does not have solid line border,so how can i add lines aroud it?
tks a lot
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: how to draw lines around wxgrid

Post by doublemax »

You want a border around the whole control? Add wxBORDER_SIMPLE to the window style flags (long style) when creating the wxGrid.
Use the source, Luke!
coderrc
Earned some good credits
Earned some good credits
Posts: 141
Joined: Tue Nov 01, 2016 2:46 pm

Re: how to draw lines around wxgrid

Post by coderrc »

if you want the border to be a particular color or size, an easy way would be to make the wxGrid the child of a panel whose BG colour is the desired border color and the margin settings of the wxGrid is the desired border thickness.
hu0118
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 23, 2017 3:23 pm

Re: how to draw lines around wxgrid

Post by hu0118 »

doublemax wrote:You want a border around the whole control? Add wxBORDER_SIMPLE to the window style flags (long style) when creating the wxGrid.
tks,it does work.
another question, how to use wxGrid::DrawColLabels ,any samples?
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: how to draw lines around wxgrid

Post by doublemax »

how to use wxGrid::DrawColLabels
It's a virtual function, you'd have to derive your own class from wxGrid and override it in order to change its behavior.

But it's uncommon to do that, what are you trying to do?

If you want to learn about his method, look at the original source code in <wxdir>\src\generic\grid.cpp
Use the source, Luke!
hu0118
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 23, 2017 3:23 pm

Re: how to draw lines around wxgrid

Post by hu0118 »

doublemax wrote:
how to use wxGrid::DrawColLabels
But it's uncommon to do that, what are you trying to do?
at the top of the grid there are two horizontal lines,one is the boder of the grid; another is the border of the col header,and i want to hide it.
img1.png
img1.png (3.92 KiB) Viewed 2441 times
Nunki
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 235
Joined: Fri Sep 14, 2012 8:26 am
Location: Kontich, Belgium
Contact:

Re: how to draw lines around wxgrid

Post by Nunki »

Hi Hu,

It seems to me that you have put the wxGrid onto a wxPanel (with a white background) which contains a wxBoxSizerV that has a spacer as first item and the grid as a second. This of course is one possibility to get this result. So what I am saying is that your problem probably is not with the wxGrid but with the undelying parent objects. Maybe you can show us the code so that we can be of more assistance.
I personally like to work with xrc files to build the screens and forms - with use of DialogBlocks - so that you can easily see upfront how your form or window will look like before you put it into your source.

regards,
Nunki
hu0118
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Oct 23, 2017 3:23 pm

Re: how to draw lines around wxgrid

Post by hu0118 »

Nunki wrote:Hi Hu,

It seems to me that you have put the wxGrid onto a wxPanel (with a white background) which contains a wxBoxSizerV that has a spacer as first item and the grid as a second. This of course is one possibility to get this result. So what I am saying is that your problem probably is not with the wxGrid but with the undelying parent objects. Maybe you can show us the code so that we can be of more assistance.
I personally like to work with xrc files to build the screens and forms - with use of DialogBlocks - so that you can easily see upfront how your form or window will look like before you put it into your source.

regards,
Nunki
tks Nunki
I use wxpython,it seems that xrc does not work well in it,especially the 'subclass' did not work.
Post Reply