HAHAHA- Suck me BALLS MFC CComboBox

Apr 30, 2005 02:40

Well. after days of putting off working on it and coming back even more frustrated i have figured it out.

Figured IT out

ill write out a brain dump for yall (Includes Gerber)

Assumming you already have a CComboBox inserted into your app i bet your wondering how to interface with the data and perform checks on it. Weeelll here is how to put it into a format that you can perform tests on. something tangible

OKAY. first off you add the box. add a bit o data in the properties by going to data and typing in the selections you want. They are seperated by ; so every new one you add ;

SO sayin gi had 3 selections
I;am;T3hRox0r5
the selections would be

I
Am
T3hRox0r5

okay. so we got data. looks all pretty. seems to do jack shit. Add a variable by right clicking on the the combo box and clicking on the ad variable. name it something you can remember

okey dokey

Create an ONSELCHANGE event by right clicking and selecting the event handler.

now lets get to the code that makes it work

okay
now insert this into your DDX

DDX_CBIndex(pDX, IDC_COMBO2, m_nDropListIndex);
DDX_CBString(pDX, IDC_COMBO2, m_strDropList);
DDX_Control(pDX, IDC_COMBO2, m_DropList);

what this does is associate your Combo box with those 3 Strings/ints

next go outside just above the DDX and assign the variables
int m_nDropListIndex;
CString m_strDropList;
(hint the new variable you put in the add variable wizard should be m_DropList)
it is CASE SENSITIVE. but if your a programmer you know that.

so anyways next the event handler

UpdateData();

if( m_nDropListIndex < 0 ) return;

CString str;
m_DropList.GetLBText( m_nDropListIndex, str );
CString Out;
Out.Format( "Drop List Selection => index %d\n%s", m_nDropListIndex, str );
AfxMessageBox( Out );

okaydokey

Put that inside the onselchange bla bla class

now
what does it do

basically. you get an AFX msg box stating all the crap you selected and makes life o so wonderful. i hope this helps yall
Previous post Next post
Up