Click here to Skip to main content
16,013,440 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: pointer to an array... "char" Pin
Christian Graus29-May-02 14:37
protectorChristian Graus29-May-02 14:37 
GeneralRe: pointer to an array... "char" Pin
Nish Nishant29-May-02 14:56
sitebuilderNish Nishant29-May-02 14:56 
GeneralRe: pointer to an array... "char" Pin
Christian Graus29-May-02 15:16
protectorChristian Graus29-May-02 15:16 
GeneralRe: pointer to an array... "char" Pin
Nish Nishant29-May-02 15:27
sitebuilderNish Nishant29-May-02 15:27 
GeneralRe: pointer to an array... "char" Pin
Christian Graus29-May-02 15:48
protectorChristian Graus29-May-02 15:48 
GeneralRe: pointer to an array... "char" Pin
Orbital^29-May-02 21:19
Orbital^29-May-02 21:19 
GeneralRe: pointer to an array... "char" Pin
SilverShalkin30-May-02 2:38
SilverShalkin30-May-02 2:38 
GeneralFlexGrid Sort Pin
29-May-02 13:31
suss29-May-02 13:31 
zenix2 (Visitor) May 29, 2002
Hi, I have this simple little program I need to complete for a course I am taking and am finding it impossible to organize my Grid.
The code I have so far is:
void CFGridDlg::LoadData()
{
//Get the grid row count
int liCount;
//Initialize the random number generator
srand((unsigned)time(NULL));
//Create and array
for (liCount = m_ctlFGrid.GetFixedRows();
liCount < m_ctlFGrid.GetRows(); liCount++)
{

//Generate the first Column (Jan) values
//m_ctlFGrid.SetTextArray(GenID(liCount, 0), StringValue(1));
//Generate the second column (Jan) values
m_ctlFGrid.SetTextArray(GenID(liCount, 1), StringValue(1));
//Generate the third column (Feb) values
m_ctlFGrid.SetTextArray(GenID(liCount, 2), StringValue(1));
//Generate the fourth column (Mar) values
m_ctlFGrid.SetTextArray(GenID(liCount, 3), StringValue(1));
//Generate the fifth column (Apr) values
m_ctlFGrid.SetTextArray(GenID(liCount, 4), StringValue(1));
//Generate the sixth column (May) values
m_ctlFGrid.SetTextArray(GenID(liCount, 5), StringValue(1));
//Generate the seventh colummn (Jun) values
m_ctlFGrid.SetTextArray(GenID(liCount, 6), StringValue(1));
DoSort();
}
}

int CFGridDlg::GenID(int m_iRow, int m_iCol)
{
//Get number of columns
int liCols = m_ctlFGrid.GetCols();
//Generate ID's. based on number of Rows, the current row, and the current column
return (m_iCol + liCols * m_iRow);
}

CString CFGridDlg::StringValue(int m_iColumn)
{
//The return Str.
CString reStr;
//Random Value ID
int raCase;
//Set the selection to column 1
//m_ctlFGrid.SetCol(1);

{
//Generate random val.
raCase = (rand() % 5);
//What val was generated?
switch (raCase)
{
case 0: //Rent
reStr = "$650.00";
break;
case 1: //Insurance
reStr = "$259.00";
break;
case 2: //Utilities
reStr = "$130.00";
break;
case 3: //Car payment
reStr = "$220.00";
break;
case 4: //Loans
reStr = "$60.00";
break;
default: //Credit cards
reStr = "$30.00";
break;
}
}
return reStr;
}

void CFGridDlg::DoSort()
{
//Set the current column to column 1
m_ctlFGrid.SetCol(1);
//Set the selection to all columns
m_ctlFGrid.SetColSel((m_ctlFGrid.GetCols() - 1));
//Ascending sort
m_ctlFGrid.SetSort(0);
}
I have experimented with all I could think of and have reached wits end I think. The top row is supposed to be Jan - June and column 0 is supposed to be "Rent/Mortg., Insurance, Utilites, Car Payment, Loans, and Credit cards." I've been able to set all this up, but the values in order for the columns by row are supposed to be 650.00, 259.00, 130.00, 220.00, 60.00, 30.00"
My code makes multiple entry of the same values and leaves some entries out.
Your assistance would be really appreciated.

Thanks,
Garry
GeneralRe: FlexGrid Sort Pin
Christian Graus29-May-02 15:09
protectorChristian Graus29-May-02 15:09 
GeneralRe: FlexGrid Sort Pin
29-May-02 15:38
suss29-May-02 15:38 
GeneralCreate form controls at runtime Pin
Aaron Schaefer29-May-02 12:55
Aaron Schaefer29-May-02 12:55 
GeneralRe: Create form controls at runtime Pin
Matt Gullett29-May-02 12:52
Matt Gullett29-May-02 12:52 
GeneralRe: Create form controls at runtime Pin
Aaron Schaefer29-May-02 13:09
Aaron Schaefer29-May-02 13:09 
Generalfstream issues Pin
Alan Chambers29-May-02 10:45
Alan Chambers29-May-02 10:45 
GeneralRe: fstream issues Pin
Joaquín M López Muñoz29-May-02 11:12
Joaquín M López Muñoz29-May-02 11:12 
GeneralRe: fstream issues Pin
Alan Chambers29-May-02 11:21
Alan Chambers29-May-02 11:21 
GeneralProblem converting a CComBSTR to LPCTSTR with CW2CT Pin
JC Gauthier29-May-02 10:24
JC Gauthier29-May-02 10:24 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
soptest29-May-02 12:25
soptest29-May-02 12:25 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
JC Gauthier30-May-02 4:27
JC Gauthier30-May-02 4:27 
GeneralRe: Problem converting a CComBSTR to LPCTSTR with CW2CT Pin
soptest30-May-02 8:36
soptest30-May-02 8:36 
General_popen issue Pin
Stew29-May-02 9:41
Stew29-May-02 9:41 
GeneralRe: _popen issue Pin
Joaquín M López Muñoz29-May-02 9:46
Joaquín M López Muñoz29-May-02 9:46 
GeneralRe: _popen issue Pin
soptest29-May-02 9:56
soptest29-May-02 9:56 
GeneralWeird Keyboard Hooking Issue Pin
John Aldrich29-May-02 9:02
John Aldrich29-May-02 9:02 
GeneralRe: Weird Keyboard Hooking Issue Pin
Joaquín M López Muñoz29-May-02 9:34
Joaquín M López Muñoz29-May-02 9:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.