A question about wxListCtrl and wxLC_VRULES....please help. Topic is solved

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
webmasterpdx
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Jun 25, 2009 2:43 am
Location: Portland, Oregon
Contact:

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

Post by webmasterpdx » Thu Jun 25, 2009 2:51 am

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

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Thu Jun 25, 2009 5:00 am

I have the opposite with VRULES showing but HRULES not showing, in Mac.

Please supply a code sample of the issue.

regards.
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

webmasterpdx
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Jun 25, 2009 2:43 am
Location: Portland, Oregon
Contact:

Post by webmasterpdx » Thu Jun 25, 2009 5:35 am

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]

webmasterpdx
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Jun 25, 2009 2:43 am
Location: Portland, Oregon
Contact:

Post by webmasterpdx » Thu Jun 25, 2009 8:51 am

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

Post Reply