StrataFrame Forum

How to add actual record number and total record number

http://forum.strataframe.net/Topic15109.aspx

By Juan Carlos Pazos - 3/22/2008

Hi

I have a maintenance form, I want to show the number of the actual record and the total number of records, I have this:

Private Sub BO_Publicaciones_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles BO_Publicaciones.Navigated

'-- Establish Locals

Dim lcMsg As String

lcMsg = Me.BO_Publicaciones.CurrentRowIndex.ToString() & " 0f " & Me.BO_Publicaciones.Count.ToString()

Me.LabelControlNumberOfrecords.Text = lcMsg

End Sub

This works for the total number, but the first record is 0 and if I have 17 records navigating goes 0, 1,2...16 I know that the count is correct but I need to star in 1 not in 0.

Thanks for your help

Regards

By Peter Jones - 3/22/2008

Hi Jaun,

Most indexes are 0 based so, to fix the display, you could try (haven't tested this so syntax may not be 100% correct):

lcMsg = String.Format("{0} of {1}", Me.BO_Publicaciones.CurrentRowIndex + 1, Me.BO_Publicaciones.Count + 1)

String.Format tends to be a better way to concatinate data like this.

Cheers, Peter

By Edhy Rijo - 3/22/2008

Peter Jones (03/22/2008)
Hi Jaun,

Most indexes are 0 based so, to fix the display, you could try (haven't tested this so syntax may not be 100% correct):

lcMsg = String.Format("{0} of {1}", Me.BO_Publicaciones.CurrentRowIndex + 1, Me.BO_Publicaciones.Count + 1)

String.Format tends to be a better way to concatinate data like this.

Cheers, Peter

Hi Peter, Juan,

Actually you don't need to add "+ 1" to the BO.Count property since it will have the corrected total count number.  So the code should be:

lcMsg = String.Format("{0} of {1}", Me.BO_Publicaciones.CurrentRowIndex + 1, Me.BO_Publicaciones.Count)

By Juan Carlos Pazos - 3/23/2008

Hi Edji, Peter

I try both, Edji yours was the correct one, if I have 17 records and use Peter's code the it tells me that are 18 records.

Thanks both for your help and take the time to point me in the rigth direction.

Regards

Thanks

Hi Peter, Juan,

Actually you don't need to add "+ 1" to the BO.Count property since it will have the corrected total count number.  So the code should be:

lcMsg = String.Format("{0} of {1}", Me.BO_Publicaciones.CurrentRowIndex + 1, Me.BO_Publicaciones.Count)

By Edhy Rijo - 3/23/2008

Hola Juan Carlos,

Glad to be of any help, even though I had to try the code before posting because I am also new to SF Tongue.

Even though I live in USA for many years I am from Dominican Republic and do speak Spanish in case you or anyone else need some help in Spanish, well your English is pretty good, so I don't think you'll need it Cool

By Trent L. Taylor - 3/24/2008

Just FYI...any collection count will always return the actual count.  This is not just specific to the SF BOs, but any collection or array in .NET.  The only time that you have to take the zero based logic into account is when dealing with an index...this will always be zero based.