[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to add a second line to a datagrid footer

Posted on 2006-07-13
11
Medium Priority
?
355 Views
Last Modified: 2012-06-21
Hi everyone, I am working on my first VB .Net application and one of my tasks is to add a second line in the footer of a datagrid.  On this line they want a previously calculated field to show up under one of the columns.  Can you please show me how to add this second line and how to line the fields up under specific columns.  
 
FOOTER

TOTAL | TOTAL | TOTAL               | TOTAL                   | TOTAL                   | TOTAL
                                                     TEXT for TOTAL2       VALUE FOR TOTAL2


Here is the code in the datagrid1_itemcreated procedure that creates the first line of the footer:

If (e.Item.ItemType = ListItemType.Footer) Then

            e.Item.Cells(2).Text = "Subtotal"
            e.Item.Cells(2).HorizontalAlign = HorizontalAlign.Right

            e.Item.Cells(3).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(3).Text = Format(intTotal1, "$###,###,###,##0.00")

            e.Item.Cells(5).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(5).Text = Format(intTotal2, "$###,###,###,##0.00")

            e.Item.Cells(6).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(6).Text = Format(intTotal3, "$###,###,###,##0.00")

            e.Item.Cells(7).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(7).Text = Format(intTotal4, "$###,###,###,##0.00")

            e.Item.Cells(8).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(8).Text = Format(intTotal5, "$###,###,###,##0.00")
           
        End If

Thank you,
Paul
0
Comment
Question by:paulmena
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 10

Expert Comment

by:vadim63
ID: 17100594
e.Item.Cells(5).Text = Format(intTotal2, "$###,###,###,##0.00") &  vbCrLf
e.Item.Cells(5).Text += "TEXT for TOTAL2"
0
 

Author Comment

by:paulmena
ID: 17101547
Hi vadim63, thanks for taking a look.  I tried it 2 ways but it doesn't seem to be working the way I expected it would.  

1.added the vbCrLf like this:

e.Item.Cells(5).Text = Format(intTotal2, "$###,###,###,##0.00") & vbCrLf
e.Item.Cells(5).Text += "TEXT for TOTAL2"

what this did is it overwrote the value that is in the first row total without adding another line.

2. added the vbCrLf to the end of the first row:

            e.Item.Cells(2).Text = "Subtotal"
            e.Item.Cells(2).HorizontalAlign = HorizontalAlign.Right

            e.Item.Cells(3).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(3).Text = Format(intTotal1, "$###,###,###,##0.00")

            e.Item.Cells(5).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(5).Text = Format(intTotal2, "$###,###,###,##0.00")

            e.Item.Cells(6).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(6).Text = Format(intTotal3, "$###,###,###,##0.00")

            e.Item.Cells(7).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(7).Text = Format(intTotal4, "$###,###,###,##0.00")

            e.Item.Cells(8).HorizontalAlign = HorizontalAlign.Right
            e.Item.Cells(8).Text = Format(intTotal5, "$###,###,###,##0.00") & vbCrLf

            e.Item.Cells(5).Text = Format(intTotal2, "$###,###,###,##0.00")
            e.Item.Cells(5).Text += "TEXT for TOTAL2"

This had the same result as #1.  It overwrote the total on the first row without adding an additional line.

Paul



0
 
LVL 10

Expert Comment

by:vadim63
ID: 17101617
That's because of your row heght is to small. I guess there's 16 by default. Set it higher. (let's say 32)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:vadim63
ID: 17101646
I don't remember the datagrids. Now I'm using DataGridView. There's a property "Autosize Row Height".
0
 

Author Comment

by:paulmena
ID: 17101953
vadim63, I changed the row height to 100 and the value on the first row is still getting overwritten. No line as been added.

Paul  
0
 
LVL 10

Expert Comment

by:vadim63
ID: 17102169
What control is that? Where did you get "e.Item.Cells ..."? Is that DataGrid, or DataGridView?
0
 

Author Comment

by:paulmena
ID: 17102468
Its from a DataGrid.  

This is the beginning of the procedure.
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated

        If (e.Item.ItemType = ListItemType.Footer) Then

            e.Item.Cells(2).Text = "Subtotal"
            e.Item.Cells(2).HorizontalAlign = HorizontalAlign.Right



0
 
LVL 10

Expert Comment

by:vadim63
ID: 17102537
O God! You're talking about web application.
0
 
LVL 10

Accepted Solution

by:
vadim63 earned 2000 total points
ID: 17102721
OK, If we're talking about web grid, your code should be like this:

e.Item.Cells(5).Text = Format(intTotal2, "$###,###,###,##0.00") &  "<br>" & "TEXT for TOTAL2"
0
 

Author Comment

by:paulmena
ID: 17102754
Hi vadim63, that worked perfectly.  Thank you for helping me out.

Paul
0
 
LVL 10

Expert Comment

by:vadim63
ID: 17102777
Thank you for the points.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question