Okay - After several days of trying to get my own data from a DataBase type into a ListCtrl i have brought it back to the Sample Program, and configured how i am doing it in the real program.
I have a GUI file and the Main file.
The main file doesn't seem to compile on :
For Local i:Int = 0 Until 4
m_listCtrlTEST.InsertItemInReportView(i)
Next
m_listCtrlTEST is the listctrl from the gui file.
it complains about InsertItemInReportView though and not being able to find it. This is in the seperate MyListCtrl type, based on the sample. I have added the listctrl as a field of MyListCtrl on the off chance that helps...
I have a seperate TDataSet (not being used in this example yet) which i planned to use later.
Any suggestions welcomed.
ListCtrlTestGUI.bmx
ListCtrlTest.bmx
Edited 08 March 2008 to stretch as the window is widened.
I have a GUI file and the Main file.
The main file doesn't seem to compile on :
For Local i:Int = 0 Until 4
m_listCtrlTEST.InsertItemInReportView(i)
Next
m_listCtrlTEST is the listctrl from the gui file.
it complains about InsertItemInReportView though and not being able to find it. This is in the seperate MyListCtrl type, based on the sample. I have added the listctrl as a field of MyListCtrl on the off chance that helps...
I have a seperate TDataSet (not being used in this example yet) which i planned to use later.
Any suggestions welcomed.
ListCtrlTestGUI.bmx
' ' BlitzMax code generated with wxCodeGen v1.00 : 02 Mar 2008 15:03:08 ' ' ' PLEASE DO "NOT" EDIT THIS FILE! ' SuperStrict Import wx.wxFrame Import wx.wxListCtrl Import wx.wxPanel Import wx.wxWindow Type MyFrame2Base Extends wxFrame Field m_panel2:wxPanel Field m_listCtrlTEST:wxListCtrl Const IDListCtrlTEST:Int = 1000 Method Create:MyFrame2Base(parent:wxWindow = Null,id:Int = wxID_ANY, title:String = "", x:Int = -1, y:Int = -1, w:Int = 500, h:Int = 300, style:Int = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL) Return MyFrame2Base(Super.Create(parent, id, title, x, y, w, h, style)) End Method Method OnInit() Local bSizer18:wxBoxSizer bSizer18 = New wxBoxSizer.Create(wxVERTICAL) m_panel2 = New wxPanel.Create(Self, wxID_ANY,,,,, wxTAB_TRAVERSAL) Local bSizer19:wxBoxSizer bSizer19 = New wxBoxSizer.Create(wxVERTICAL) m_listCtrlTEST = New wxListCtrl.Create(m_panel2, IDListCtrlTEST,,,,, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL) m_listCtrlTEST.SetMinSize(400,200) bSizer19.Add(m_listCtrlTEST, 1, wxALL, 5) m_panel2.SetSizer(bSizer19) m_panel2.Layout() bSizer18.Add(m_panel2, 1, wxEXPAND | wxALL, 5) SetSizer(bSizer18) Layout() End Method End Type
ListCtrlTest.bmx
' ' Example application stub generated by wxCodeGen v1.00 : 02 Mar 2008 15:03:08 ' SuperStrict Framework wx.wxApp Import "ListCtrlTestGUI.bmx" Import brl.LinkedList New MyApp.run() Type MyApp Extends wxApp Field frame:MyFrame2 Method OnInit:Int() ?macos ' make the default Mac font for controls not so big wxSystemOptions.SetOption(wxWINDOW_DEFAULT_VARIANT, wxWINDOW_VARIANT_SMALL) ? wxInitAllImageHandlers() wxImage.AddHandler( New wxXPMHandler ) ' for Mac/Win32 (it is default on Linux) Local frame:MyFrame2 = MyFrame2(New MyFrame2.Create(, , "C2D TaskList ListCtrl Test")) frame.show() SetTopWindow(frame) Return True End Method End Type Type MyFrame2 Extends MyFrame2Base ' added from Bruceys Example Field imageListSmall:wxImageList ' my columns to be used for the TDataSet ***** but NOT used in this example Global s_ColumnTitles:String[] = ["Column1","Column2","Column3","Column4","Column5"] Method OnInit() Super.OnInit() ' added from Bruceys Example imageListSmall = New wxImageList.Create(16, 16, True) RecreateList(wxLC_REPORT | wxLC_SINGLE_SEL) End Method Method InitWithReportItems() m_listCtrlTEST.SetImageList(imageListSmall, wxIMAGE_LIST_SMALL) ' note that under MSW For SetColumnWidth() To work we need To create the ' items with images initially even If we specify dummy image id Local itemCol:wxListItem = New wxListItem.Create() itemCol.SetText("Column 1") itemCol.SetImage(-1) m_listCtrlTEST.InsertColumnItem(0, itemCol) itemCol.SetText("Column 2") itemCol.SetAlign(wxLIST_FORMAT_CENTRE) m_listCtrlTEST.InsertColumnItem(1, itemCol) itemCol.SetText("Column 3") itemCol.SetAlign(wxLIST_FORMAT_RIGHT) m_listCtrlTEST.InsertColumnItem(2, itemCol) ' To speed up inserting we hide the control temporarily m_listCtrlTEST.Hide() For Local i:Int = 0 Until 4 m_listCtrlTEST.InsertItemInReportView(i) Next m_listCtrlTEST.Show() ' we leave all mask fields To 0 And only change the colour Local item:wxListItem = New wxListItem.Create() item.SetId(0) item.SetTextColour(wxRED()) m_listCtrlTEST.SetItem( item ) item.SetId(2) item.SetTextColour(wxGREEN()) m_listCtrlTEST.SetItem( item ) item.SetId(4) item.SetTextColour(wxLIGHT_GREY()) item.SetFont(wxITALIC_FONT()) item.SetBackgroundColour(wxRED()) m_listCtrlTEST.SetItem( item ); m_listCtrlTEST.SetTextColour(wxBLUE()) m_listCtrlTEST.SetColumnWidth( 0, wxLIST_AUTOSIZE ) m_listCtrlTEST.SetColumnWidth( 1, wxLIST_AUTOSIZE ) m_listCtrlTEST.SetColumnWidth( 2, wxLIST_AUTOSIZE ) ' Set images in columns m_listCtrlTEST.SetItemColumnImage(1, 1, 0) Local info:wxListItem = New wxListItem.Create() info.SetImage(0) info.SetId(3) info.SetColumn(2) m_listCtrlTEST.SetItem(info) ' test SetItemFont too m_listCtrlTEST.SetItemFont(0, wxITALIC_FONT()) End Method ' recreate the list control with the New flags Method RecreateList(flags:Int, withText:Int = True) If m_listCtrlTEST Then m_listCtrlTEST.Free() End If m_listCtrlTEST= MyListCtrl(New MyListCtrl.Create(panel, LIST_CTRL, ,, ,, flags | wxSUNKEN_BORDER | wxLC_EDIT_LABELS)) Select flags & wxLC_MASK_TYPE Case wxLC_LIST ' InitWithListItems() Case wxLC_ICON ' InitWithIconItems(withText) Case wxLC_SMALL_ICON ' InitWithIconItems(withText, True) Case wxLC_REPORT If flags & wxLC_VIRTUAL Then ' InitWithVirtualItems() Else InitWithReportItems() End If Default End Select DoSize() End Method Method DoSize() If Not logWindow Then Return End If Local w:Int, h:Int GetClientSize(w, h) Local y:Int = (2 * h) / 3 listCtrl.SetDimensions(0, 0, w, y) logWindow.SetDimensions(0, y + 1, w, h - y) End Method End Type Type MyListCtrl Extends wxListCtrl Field m_listCtrlTEST:wxListCtrl Method InsertItemInReportView(i:Int) Local buf:String = "This is item " + i Local tmp:Int = InsertImageStringItem(i, buf, 0) buf = "Col 1, item " + i SetStringItem(tmp, 1, buf) buf = "Item " + i + " in column 2" SetStringItem(tmp, 2, buf) End Method End Type Type TDataSet Field c1:Int Field c2:String Field c3:String Field c4:Int Field c5:String Global list:TList Method Init:TDataSet() Return Self End Method Function Create(RowNumber:Int) Local DataSet:TDataSet = New TDataSet DataSet.c1 = RowNumber DataSet.c2 = "Column 2 for Row Number " + RowNumber DataSet.c3 = "Column 3 for Row Number " + RowNumber DataSet.c4 = 100 + RowNumber DataSet.c5 = "Column 5 for Row Number " + RowNumber + " Has a long piece of Data to display" If Not List Then List = CreateList() List.AddLast( DataSet ) End Function End Type
Edited 08 March 2008 to stretch as the window is widened.