none
counting number of characters in each row of column in table and set width RRS feed

  • Question

  • I am having one table daily_table showing its data in report viewer. Table has various column such as part no, part name I want to set width of column as per the maximum number of characters in that column rows. I am not able to loop through all rows in each column. so please tell me how to count number of characters in each row of column and set maximum character size as a width to that column. Please help.
    Monday, January 4, 2016 4:38 AM

Answers

  • You would have to get the data in each column you are talking about into a variable. A string variable.

    dim Test  as String = "Test"

    dim len as Int32

    len = Test.Lenght()

    len will be 4..

    You loop through all columns in each row.

    http://www.dotnetperls.com/datarow-vbnet

    http://codedisplay.com/datatable-foreach-loop-to-read-records-c-vb-net-asp-net/

    You can do a columnname.ToString().Length().

    It is something to look at.

    Monday, January 4, 2016 6:38 AM
  • Your question is unclear, are you talking about rdlc report? What do you mean by "loop through all rows in each column"? Also what is this Table you talking about DataTable or SQL table...?

    >>>so please tell me how to count number of characters in each row of column and set maximum character size as a width to that column. Please help.

    So if you find 10000 characters in that column string What will be the width in this case?

    You shouldn't be setting the column width to the chars count because you cannot expect what will be there, normally we work on row height rather and keep the column width fixed. Because the rows can expand on multiple pages, while setting dynamic column width can break the same page outside of the printing area.


    Fouad Roumieh


    Monday, January 4, 2016 7:20 AM

All replies

  • You would have to get the data in each column you are talking about into a variable. A string variable.

    dim Test  as String = "Test"

    dim len as Int32

    len = Test.Lenght()

    len will be 4..

    You loop through all columns in each row.

    http://www.dotnetperls.com/datarow-vbnet

    http://codedisplay.com/datatable-foreach-loop-to-read-records-c-vb-net-asp-net/

    You can do a columnname.ToString().Length().

    It is something to look at.

    Monday, January 4, 2016 6:38 AM
  • Your question is unclear, are you talking about rdlc report? What do you mean by "loop through all rows in each column"? Also what is this Table you talking about DataTable or SQL table...?

    >>>so please tell me how to count number of characters in each row of column and set maximum character size as a width to that column. Please help.

    So if you find 10000 characters in that column string What will be the width in this case?

    You shouldn't be setting the column width to the chars count because you cannot expect what will be there, normally we work on row height rather and keep the column width fixed. Because the rows can expand on multiple pages, while setting dynamic column width can break the same page outside of the printing area.


    Fouad Roumieh


    Monday, January 4, 2016 7:20 AM