none
Report Designer Rows RRS feed

  • Question

  • Hi - Can anyone assist me with a few specific questions regarding report designing in Visual Studio? I'm an accountant by trade, so most of this is very new to me:

    1) I'd like to add customized shading to my rows so that every other row of data on the report will be shaded with light gray.  It'll be easier on user's eyes.  Is this possible through code?

    2) Somewhat relatedly, is it possible to insert a blank row into a report?  The data itself is being sourced from a data warehouse, and I'm simply designing the report in VS.  It would be very beneficial to be able to break up the data.

    Thanks!

    Matt 

    • Moved by 宝宝徐 Thursday, September 15, 2016 5:34 AM
    Wednesday, September 14, 2016 3:52 PM

All replies

  • Hi Matt,

    Thanks for your post.

    Since Our forum is discussing about VS general question like how to set/configure Visual Studio and Visual Studio tools.

    As your question is about report control, I will help you move this case to other Forums  Visual Studio Report Controls  forum for dedicated support

    Thank you for your understanding.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Thursday, September 15, 2016 5:26 AM
  • Matt,

         I am not a Microsoft employee.  They have not been supporting this for a while it seems.  So I am just trying to help.  I am using Microsoft's Report Writer in Visual Studio 2015.

         1) Yes.  I get shading on every other line automatically if I select and drag & drop a control that I put on the rdlc file called "Tablix".  In the "Background Color" property of the Tablix I set to this expression:      

    =iif(RowNumber(Nothing) Mod 2, "White", "WhiteSmoke")

         2) Yes.  In your C# or VB view model code that interacts with your report, you obviously have code to connect to your data warehouse and gather the data.  You could use Linq to filter, order, and or group your data prior to sending it to the report. Below I am gathering my data and putting it line by line into a datatable that I hand to the report to show.  Along the way, I do special processing on particular lines.  Your challenge would be deciding where out of the data to do your blank line, such as maybe looking for a keyword.

            private void LoadReport()
            {
                var activeDriversReportView = GetView() as ActiveDriversReportView;
                if (activeDriversReportView == null) 
                    return;
    
                ReportViewer report = activeDriversReportView.ActiveDriversReport;
                report.LocalReport.DataSources.Clear();
                
                _driverLogRepository = new DriverLogRepository(_connectionStringName);
    
                // Get a list of driver log entries that have a 'begin day' but not an 'end day'
                var results = _driverLogRepository.GetRecentDriverLogEntries().OrderBy(x => x.CreatedDate).GroupBy(x => x.LoginId, y => y);
    
                // Since our validation is spotty, there are often a lot of drivers who are in this
                // list twice: they have lots of begin days and not a corresponding number of end days.
                // We need to filter the results to only show the most recent applicable log entry
    
                DataTable dt = new ActiveDriversReport.ActiveDriversReportDataDataTable();
    
                foreach (var group in results)
                {
                    var k = @group.Key;
                    var login = _loginRepository.GetLoginById(k);
                    var sortedGroup = @group.OrderBy(x => x.CreatedDate);
                    var lastEntry = sortedGroup.Last();
    
                    if ((!login.IsActive) || (lastEntry.EndDate != null)) 
                        continue;
    
                    var row = dt.NewRow();
                    row["DriverLastName"] = login.LastName;
                    row["DriverFirstName"] = login.FirstName;
                    row["DriverUsername"] = login.Username;
                    row["BeginDayDateTime"] = lastEntry.BeginDate;
                    dt.Rows.Add(row);
                }
    
                report.LocalReport.DataSources.Add(new ReportDataSource("ActiveDriversReportData", dt));
                report.LocalReport.ReportPath = @"Reports/AdminReports/ActiveDriversReport.rdlc";
                report.RefreshReport();
            }
        }


    MSDN


    • Proposed as answer by Eric Wood8 Thursday, March 1, 2018 3:57 PM
    • Edited by Eric Wood8 Wednesday, March 7, 2018 3:26 PM Correction
    Thursday, March 1, 2018 3:55 PM