?
Solved

lining up the values

Posted on 2011-03-22
4
Medium Priority
?
232 Views
Last Modified: 2012-05-11
I seem to be very close to an answer but this is getting me.
Windows form - VS2010 - C#
The first problem is that I'm dealing with tabulated data in the wrong kind of control but I'm stuck for output options (3rd party)

I have to out a grid of info
that is basically an hourly rate * hours worked (for the purpose of the question I've kept the numbers basic)
The code shows what I have and the image shows what I'm trying to output
Problem being that I only want to have the start of each row show the x hrs/wk and need a new line after each dollar value has been outputted.
int hoursPerWeek, payRate;
            for (payRate = 5; payRate <= 10; payRate++)
            {
                for (hoursPerWeek = 10; hoursPerWeek <= 20; hoursPerWeek++)
                {
                    string prefix = hoursPerWeek + " hrs/week: ";
                    memo.AppendText(prefix);
                    prefix = "";
                    memo.AppendText((hoursPerWeek * payRate) + "\t\t");
                    if (payRate == 10)
                    {
                        memo.AppendText("\n");
                    }
                }

Open in new window

grid.gif
0
Comment
Question by:QPR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 2000 total points
ID: 35195696
I tried this - see the code.

Output:


10 hrs/week:             50            60            70            80            90            100            
11 hrs/week:             55            66            77            88            99            110            
12 hrs/week:             60            72            84            96            108            120            
13 hrs/week:             65            78            91            104            117            130            
14 hrs/week:             70            84            98            112            126            140            
15 hrs/week:             75            90            105            120            135            150            
16 hrs/week:             80            96            112            128            144            160            
17 hrs/week:             85            102            119            136            153            170            
18 hrs/week:             90            108            126            144            162            180            
19 hrs/week:             95            114            133            152            171            190            
20 hrs/week:             100            120            140            160            180            200            

StringBuilder memo = new StringBuilder();
            int hoursPerWeek, payRate;
            for (hoursPerWeek = 10; hoursPerWeek <= 20; hoursPerWeek++) 
            {
                string prefix = hoursPerWeek + " hrs/week: "+ "\t\t";
                memo.Append(prefix);
                for(payRate = 5; payRate <= 10; payRate++)
                {
                    memo.Append((hoursPerWeek * payRate) + "\t\t");
                    if (payRate == 10)
                    {
                        memo.AppendLine( );
                    }
                }
            }
            System.Diagnostics.Debug.WriteLine(memo.ToString());

Open in new window

0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 35195702
You may need some formatting if you want to align columns properly but this is a bit different story...
0
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 35195715
0
 
LVL 29

Author Closing Comment

by:QPR
ID: 35195767
perfect
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question