473,499 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I know this is Probably obvious but I am new and stuck!!

2 New Member
Here is my problem, please excuse my newbieness..

I have a datagrid on a form where you can put in numbers for a spacing.
I am trying to get the code to place the item at the first space dictated by the first row of the datagrid, then for the second row add that number to the first row etc.

If you look at the picture what I want to do is place an item at 120 on the first row. Then the second Row I want to add that to the first one so the item would be placed at 240 inches. Then the third row added to the total of the first to so it would be at 360.

Right now xVal is where the items are being placed.

Here is the code I have so far which isnt right. It puts everything at 120 inches.
Thanks

Expand|Select|Wrap|Line Numbers
  1. double xVal = 0;
  2.  
  3. DataGridViewRow EndPostSpacing = d_Endpost.Rows[i];
  4. string PostSpacing = EndPostSpacing.Cells["EPSpacing"].Value.ToString();
  5. double PostSpacingTotal = I2M(double.Parse(PostSpacing.ToString()));
  6.  if (PostSpacingTotal == 0)
  7.  {
  8.        if (xVal == 0)
  9.  {
  10.         PostSpacingTotal = 0;
  11.   }
  12.  
  13.   }
  14.  xVal += PostSpacingTotal;
Attached Images
File Type: jpg DataGrid.jpg (16.9 KB, 104 views)
Feb 6 '10 #1
1 1014
miggs
2 New Member
Ok just an update.
I have made a little progress with the added code. I can now add the first and second row together, but the third row only adds to the first and not the total of both. There is more to the for loop but this is the only portion that isn't working.

(I2M is a method I have to convert metric to imperial)

for (int i = 0; i < d_Endpost.Rows.Count -1 ; i++)
{
///Sets Endpost Spacing


DataGridViewRow EndPostSpacing = d_Endpost.Rows[i];
Double xVal = 0;

foreach(DataGridViewRow row in d_Endpost.Rows)
{
string PostSpacing = EndPostSpacing.Cells["EPSpacing"].Value.ToString();
double PostSpacingTotal = I2M(double.Parse(PostSpacing.ToString()));
Double temp = PostSpacingTotal;
if (i == 0)
{
xVal = temp;
}
else
{
xVal = temp += PostSpacingTotal;
}

}
}
Feb 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

22
3733
by: Mike Krous | last post by:
Hello All, I am having some problems modeling a relationship properly and could use some advice. My final question is at the bottom of this post (everything else is explanation). Basically what I...
14
3114
by: WUV999U | last post by:
Hi I am fairly familiar in C but not much. I want to know how I can write a html parser in C that only parses for the image file in the html file and display or print all the images found in...
2
1083
by: Jethro | last post by:
Hi all, I have a solution, which contains several projects. Each project occupies the same namespace, and compiles to s different .NET DLL e.g. MyNamespace.ThisClass is in one DLL...
4
1502
by: Adrian von Bidder | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yo! Mostly as a finger-exercise (and because I'm annoyed again and again how bad the existing solutions are), I'm hacking up a web-based forum...
28
2592
by: H J van Rooyen | last post by:
Hi, I want to write a small system that is transaction based. I want to split the GUI front end data entry away from the file handling and record keeping. Now it seems almost trivially easy...
7
5940
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
7
1644
by: PGPS | last post by:
Hi, I want to know who all clicked a particular link (cgi-script) on any website. 1. Link points to my own webserver 2. Link can be sent anyway. Either emailed or posted on a site which needs...
10
1857
by: Cliff | last post by:
Greetings, I have been trying to teach myself C++ over the past few weeks and have finally came across a problem I could not fix. I made a simple program that prints out a square or rectangle...
6
1891
by: Roger Heathcote | last post by:
sjdevnull@yahoo.com wrote: <snip> Fair point, but for sub processes that need to be in close contact with the original app, or very small functions that you'd like 100s or 1000s of it seems...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7006
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.