Page 1 of 1

A question about wxListCtrl and wxLC_VRULES....please help.

Posted: Thu Jun 25, 2009 2:51 am
by webmasterpdx
I am using wxDevC++ and am using a wxListCtrl with 3 columns.
When I set wxLC_VIRTUAL, the wxLC_VRULES works and draws vertical lines between columns. However, when I change from wxLC_VIRTUAL to wxLC_REPORT (which is what I need to use), the vertical lines do not appear. The HRULES works fine, but VRULES doesn't appear to draw any vertical lines.

Any ideas? I've searched everywhere and can't find a reference to this. I'm using wxWidgets 2.8.8

Thanks
-Donald

Posted: Thu Jun 25, 2009 5:00 am
by protocol
I have the opposite with VRULES showing but HRULES not showing, in Mac.

Please supply a code sample of the issue.

regards.

Posted: Thu Jun 25, 2009 5:35 am
by webmasterpdx
Here is my .cpp file

Code: Select all

//---------------------------------------------------------------------------
//
// Name:        testtableFrm.cpp
// Author:      donm
// Created:     6/23/2009 2:50:19 PM
// Description: testtableFrm class implementation
//
//---------------------------------------------------------------------------

#include "testtableFrm.h"

//Do not add custom headers between
//Header Include Start and Header Include End
//wxDev-C++ designer will remove them
////Header Include Start
////Header Include End

//----------------------------------------------------------------------------
// testtableFrm
//----------------------------------------------------------------------------
//Add Custom Events only in the appropriate block.
//Code added in other places will be removed by wxDev-C++
////Event Table Start
BEGIN_EVENT_TABLE(testtableFrm,wxFrame)
	////Manual Code Start
	////Manual Code End
	
	EVT_CLOSE(testtableFrm::OnClose)
END_EVENT_TABLE()
////Event Table End

testtableFrm::testtableFrm(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
	CreateGUIControls();
}

testtableFrm::~testtableFrm()
{
}

void testtableFrm::CreateGUIControls()
{
	//Do not add custom code between
	//GUI Items Creation Start and GUI Items Creation End
	//wxDev-C++ designer will remove them.
	//Add the custom code before or after the blocks
	////GUI Items Creation Start

	WxPanel1 = new wxPanel(this, ID_WXPANEL1, wxPoint(13, 12), wxSize(643, 361));

	WxListCtrl1 = new wxListCtrl(WxPanel1, ID_WXLISTCTRL1, wxPoint(24, 16), wxSize(570, 312), wxLC_REPORT | wxLC_VRULES, wxDefaultValidator, wxT("WxListCtrl1"));
	WxListCtrl1->InsertColumn(0,wxT("DESCRIPTION"),wxLIST_FORMAT_CENTER,200 );
	WxListCtrl1->InsertColumn(0,wxT("TYPE"),wxLIST_FORMAT_CENTER,100 );
	WxListCtrl1->InsertColumn(0,wxT("ID"),wxLIST_FORMAT_LEFT,100 );

	SetTitle(wxT("testtable"));
	SetIcon(wxNullIcon);
	SetSize(8,8,676,415);
	Center();
	
	////GUI Items Creation End
	
	UpdateList();
}

void testtableFrm::OnClose(wxCloseEvent& event)
{
	Destroy();
}

/*
// Virtual ListCtrl
wxString wxListCtrl::OnGetItemText(long item, long column) const
{   
    return wxString::Format(_T("Column %ld of item %ld"), column, item);
}
*/

void testtableFrm::UpdateList()
{
    WxListCtrl1->SetItemCount(1000000);
    
    long itemIndex = 0;
    int count = 100;
    for(int i=0; i < count; ++i)
    {
        itemIndex = WxListCtrl1->InsertItem(0, wxString::Format(wxT("%d"), i));
        WxListCtrl1->SetItem(itemIndex, 1, "Column 1");
        WxListCtrl1->SetItem(itemIndex, 2, "Column 2");
    }
    
    
}
[/img][/code]

Posted: Thu Jun 25, 2009 8:51 am
by webmasterpdx
I found the solution to my problem. I was setting the Item Count to 1000000 because originally I was planning on using a Virtual List, but that requires deriving from the form ListCtrl component, and I don't know of a way to do that from the form designer (I like to use the form designer wherever possible). I think wxDevC++ allows you to derive using the Base Class property, but I've been unable to find instructions on how to do that.
Anyways, when I remove the SetItemCount(1000000), the VRULES work fine.

Note that for the Mac person posting here, I did find a Max version of listctrl called wxListCtrl_mac which you can find if you search on the web. It could be you need to use that.

Now, if anyone knows how to make my rightmost column align and spread in width to fit the window even when resized. Any ideas? I appreciate any help in advance.

Thanks
-Donald