Basic in wxListBox (Insert, Clear and Delete) (SOLVED) Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
vanillamonkey
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Aug 30, 2009 1:32 pm

Basic in wxListBox (Insert, Clear and Delete) (SOLVED)

Post by vanillamonkey »

Hi! This is not really my program. I just tried out a simple program to see if it would act the way my program acts. My problem is that whenever i insert items in the listbox then delete it or clear it, i cant get the program to insert again. There are no errors to this code.


My wxDevC++ -> Version number 7.0 RC6 build 7.0.0.85

Code:(.cpp)


[quote]#include "Project1Dlg.h"

BEGIN_EVENT_TABLE(Project1Dlg,wxDialog)

EVT_CLOSE(Project1Dlg::OnClose)
EVT_BUTTON(ID_INSERT,Project1Dlg::insertClick)
EVT_BUTTON(ID_DELI,Project1Dlg::deliClick)
EVT_BUTTON(ID_CLEAR,Project1Dlg::clearClick)
END_EVENT_TABLE()

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

Project1Dlg::~Project1Dlg()
{
}

void Project1Dlg::CreateGUIControls()
{
text = new wxTextCtrl(this, ID_TEXT, wxT(""), wxPoint(89, 247), wxSize(121, 19), 0, wxDefaultValidator, wxT("text"));

insert = new wxButton(this, ID_INSERT, wxT("insert"), wxPoint(212, 202), wxSize(75, 25), 0, wxDefaultValidator, wxT("insert"));

deli = new wxButton(this, ID_DELI, wxT("deli"), wxPoint(106, 203), wxSize(75, 25), 0, wxDefaultValidator, wxT("deli"));

WxButton2 = new wxButton(this, ID_WXBUTTON2, wxT("WxButton2"), wxPoint(223, 258), wxSize(1, 2), 0, wxDefaultValidator, wxT("WxButton2"));

clear = new wxButton(this, ID_CLEAR, wxT("clear"), wxPoint(13, 201), wxSize(75, 25), 0, wxDefaultValidator, wxT("clear"));

wxArrayString arrayStringFor_listbox;
listbox = new wxListBox(this, ID_LISTBOX, wxPoint(6, 9), wxSize(294, 181), arrayStringFor_listbox, wxLB_SINGLE);

SetTitle(wxT("Project1"));
SetIcon(wxNullIcon);
SetSize(8,8,320,334);
Center();
}

void Project1Dlg::OnClose(wxCloseEvent& /*event*/)
{
Destroy();
}

int n = 0;
void Project1Dlg::insertClick(wxCommandEvent& event)
{
wxString texty = text->GetValue();
listbox->Insert(texty, n);
n = n+1;

}


void Project1Dlg::deliClick(wxCommandEvent& event)
{
int del = listbox->GetSelection();
listbox->Delete(del);
}


void Project1Dlg::clearClick(wxCommandEvent& event)
{
listbox->Clear();
}
[/quote]


Thank you for your consideration.
Last edited by vanillamonkey on Thu Sep 03, 2009 8:39 am, edited 1 time in total.
protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol »

/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!
vanillamonkey
In need of some credit
In need of some credit
Posts: 9
Joined: Sun Aug 30, 2009 1:32 pm

Post by vanillamonkey »

Wow. That worked great. Thanks!
Post Reply