AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 29.11.2013, 16:14   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
In my now many report training classes I have always shown a small example on how to use the PadRight method to extend the string with additional dots(.), also called Leading Dots. I.e. like this:



In left column I have just added the Customer Name, while in the second column I’m using the method PadRigth to add additional dots(.) to the Customer Name string.
To accomplish this I have the following custom code in my Report:


Public Function MyPaddedString(ByVal Value As String)
    Return Value.PadRight(100,".")
End Function


And then in my expression in my right column I have this expression:

=Code.MyPaddedString(Fields!Customer_Name.Value)

This works fine, but I have always found that the dots(.) are to close to each when usign PadRight, so I have usually challenged the people attending my report class to come with a solution to add more space in between the dots(.), and now finally somebody, Christian Bockelmann from Agiles, took the bait and came with a solution, which I would like share with all of you.

What Christian is doing is not using the PadRight method, but checking on the lenght of the Customer Name and then applies a space and dot(.) until he reaches 100. Just like in my above PadRight soluiton.

Public Function MyPaddedStringUsingLength(ByVal Value As String)
  while(Value.Length < 100)
    if(Value.Length <> 99) then
      Value = Value + " ."
    else
      Value = Value + " "
    End if
  End while
  Return Value
End Function


Actually quite simple. So with Christians solution I can now add a new column to my PadRight example:




In the new column to right I have the following expression:

=Code.MyPaddedStringUsingLength(Fields!Customer_Name.Value)

And as you can see the leading dots now looks much better since they are now all seperated with a space.

If you want, you can download the solution here on my SkyDrive. It’s in RDLC 2008, NAV 2013 version, but you can easily upgrade to NAV 2013 R2 if you want or apply the above code to RDLC 2010 if you want. If you are not using Dynamics NAV, just open the OfflineFolder and open the solution file “OfflineReport.sln” with Visual Studio 2010 Pro or higher version of VS2010. Express version does not work with Offline Reports.

Thanks again Christian for this simple solution

/Thanks, Claus Lundstrøm, MVP for Microsoft Dynamics NAV
Abakion.com & Supplychainbox.com



Читать дальше
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:18.