Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

How to write code loop through account no on grid and add spaces to left and cut spaces on right but must all length be 15

$
0
0

I work on windows from app csharp visual studio 2015

I have windows form have datagridview name Grid1 

this grid have 5 rows and column name Account No

what i need is to loop through five rows and add spaces from left and remove spaces from right 

and in same time it must be have length 15 .

suppose i write account no  123321 what i need to do is loop through 5 records

then loop through column account no then make following

15 - length of account(123321)= 9

then add 9 spaces to left of number and not add any spaces to right 

meaning add 9 times ""

and in same time if number have right space remove it and add it to left of number 

but must length of number as 6 + spaces = 15

Example

'         123321'
'        476890 '

first one as 123321 is correct result

second one as 576890 is wrong because it have right space 

all number with spaces must be 15

so please how to do that 



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>