Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
ZTE MF283U 4G Unlocked Router (Used)
ayanthamaxi
Updated:
Sunday at 8:26 PM
ලංකාවේ හොඳම උපකාරක පන්ති සහ ගුරුවරුන් එකම තැනකින් - TopTuition.lk
dulithapathum
Updated:
Saturday at 8:07 AM
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Wednesday at 11:58 PM
Ad icon
Colombo
PXN V10 Pro Direct Drive Racing Wheel (Under Warranty)
Abdur Rahman
Updated:
Wednesday at 10:23 PM
Ad icon
USDT ණය සේවාව - USDT Loan Service
පුරවැසියා
Updated:
Wednesday at 4:54 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
C# Programing FAQ - Post here
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Ranhiru" data-source="post: 4821281" data-attributes="member: 17748"><p>Machan the first one is a problem because the column has a NULL value in it. Does the "Amount" column contain a null value??? If the "Amount" column contains NULL values, then it should be handled separately.</p><p></p><p></p><p>And for the second problem i think Amount should work :S</p><p></p><p>If amount does not seem to work, simply use the column index <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></p><p></p><p>So if the Amount column is the 3rd one, then the index is 2, because in C# its zero based indexes. </p><p></p><p></p><p>[code]int i = 0;</p><p> int Total = 0;</p><p></p><p></p><p> for (i = 0; i < costDataGridView1.Rows.Count; i++)</p><p></p><p> {</p><p> if (costDataGridView1.Rows[i].Cells[2].Value != null)</p><p> Total += Int32.Parse(costDataGridView1.Rows[i].Cells[2].Value.ToString());</p><p></p><p> }</p><p> this.textBox1.Text = Total.ToString();[/code] </p><p></p><p>So this is perfectly all right too <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /> Using the index instead of the name <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /> Notice that now i check whether the value is not null. If Int32.Parse giving you any errors, try the Convert Class. Use Convert.ToInt32(whatever)...</p><p>Hope this helps <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="Ranhiru, post: 4821281, member: 17748"] Machan the first one is a problem because the column has a NULL value in it. Does the "Amount" column contain a null value??? If the "Amount" column contains NULL values, then it should be handled separately. And for the second problem i think Amount should work :S If amount does not seem to work, simply use the column index :D So if the Amount column is the 3rd one, then the index is 2, because in C# its zero based indexes. [code]int i = 0; int Total = 0; for (i = 0; i < costDataGridView1.Rows.Count; i++) { if (costDataGridView1.Rows[i].Cells[2].Value != null) Total += Int32.Parse(costDataGridView1.Rows[i].Cells[2].Value.ToString()); } this.textBox1.Text = Total.ToString();[/code] So this is perfectly all right too :) Using the index instead of the name :) Notice that now i check whether the value is not null. If Int32.Parse giving you any errors, try the Convert Class. Use Convert.ToInt32(whatever)... Hope this helps :) [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom