Variable number of subreports on FastReport .NET - c#

I have a report that prints the information a sell. The report's Data Source is a SellReport object.
Now I want to print the information of more than one sell, but not of a fixed number of sells. I think the best way is to pass a Collection as Data Source and for each SellReport of the collection it generates a subreport.
Anyone know how to create subreports dynamically?
Thanks!

Here is example, how to create a report using code
Report report = new Report();
// register the "Products" table
report.RegisterData(dataSet1.Tables["Products"], "Products");
// enable it to use in a report
report.GetDataSource("Products").Enabled = true;
// create A4 page with all margins set to 1cm
ReportPage page1 = new ReportPage();
page1.Name = "Page1";
report.Pages.Add(page1);
// create ReportTitle band
page1.ReportTitle = new ReportTitleBand();
page1.ReportTitle.Name = "ReportTitle1";
// set its height to 1.5cm
page1.ReportTitle.Height = Units.Centimeters * 1.5f;
// create group header
GroupHeaderBand group1 = new GroupHeaderBand();
group1.Name = "GroupHeader1";
group1.Height = Units.Centimeters * 1;
// set group condition
group1.Condition = "[Products.ProductName].Substring(0, 1)";
// add group to the page.Bands collection
page1.Bands.Add(group1);
// create group footer
group1.GroupFooter = new GroupFooterBand();
group1.GroupFooter.Name = "GroupFooter1";
group1.GroupFooter.Height = Units.Centimeters * 1;
// create DataBand
DataBand data1 = new DataBand();
data1.Name = "Data1";
data1.Height = Units.Centimeters * 0.5f;
// set data source
data1.DataSource = report.GetDataSource("Products");
// connect databand to a group
group1.Data = data1;
// create "Text" objects
// report title
TextObject text1 = new TextObject();
text1.Name = "Text1";
// set bounds
text1.Bounds = new RectangleF(0, 0,
Units.Centimeters * 19, Units.Centimeters * 1);
// set text
text1.Text = "PRODUCTS";
// set appearance
text1.HorzAlign = HorzAlign.Center;
text1.Font = new Font("Tahoma", 14, FontStyle.Bold);
// add it to ReportTitle
page1.ReportTitle.Objects.Add(text1);
// group
TextObject text2 = new TextObject();
text2.Name = "Text2";
text2.Bounds = new RectangleF(0, 0,
Units.Centimeters * 2, Units.Centimeters * 1);
text2.Text = "[[Products.ProductName].Substring(0, 1)]";
text2.Font = new Font("Tahoma", 10, FontStyle.Bold);
// add it to GroupHeader
group1.Objects.Add(text2);
// data band
TextObject text3 = new TextObject();
text3.Name = "Text3";
text3.Bounds = new RectangleF(0, 0,
Units.Centimeters * 10, Units.Centimeters * 0.5f);
text3.Text = "[Products.ProductName]";
text3.Font = new Font("Tahoma", 8);
// add it to DataBand
data1.Objects.Add(text3);
// group footer
TextObject text4 = new TextObject();
text4.Name = "Text4";
text4.Bounds = new RectangleF(0, 0,
Units.Centimeters * 10, Units.Centimeters * 0.5f);
text4.Text = "Count: [CountOfProducts]";
text4.Font = new Font("Tahoma", 8, FontStyle.Bold);
// add it to GroupFooter
group1.GroupFooter.Objects.Add(text4);
// add a total
Total groupTotal = new Total();
groupTotal.Name = "CountOfProducts";
groupTotal.TotalType = TotalType.Count;
groupTotal.Evaluator = data1;
groupTotal.PrintOn = group1.Footer;
// add it to report totals
report.Dictionary.Totals.Add(groupTotal);
// run the report
report.Show();
And example for Data Source:
private int[] FArray;
/ create report instance
Report report = new Report();
/ register the array
report.RegisterData(FArray, "Array");
You can use a list instead of int[]
And look at example \Demos\C#\DataFromBusinessObject

Related

UICollectionview - removing right padding/margin?

I am trying to do a slideshow display of items and I have an issue where there is a mysterious padding added to the first cell(on the left side) and last cell(right side) as shown below and demonstrated by the black box
DataSource datasource = new DataSource(Vcollection, PageControl, this);
Vcollection.Source = datasource;
doRefreshList = true;
Vcollection.CollectionViewLayout = new UICollectionViewFlowLayout()
{
ItemSize = Vcollection.Frame.Size,
HeaderReferenceSize = new CGSize(0, 0),
SectionInset = UIEdgeInsets.Zero,
ScrollDirection = UICollectionViewScrollDirection.Horizontal,
MinimumInteritemSpacing = 0f, // minimum spacing between cells
MinimumLineSpacing = 0f,
SectionInsetReference = UICollectionViewFlowLayoutSectionInsetReference.ContentInset,
};
Vcollection.ContentInset = UIEdgeInsets.Zero;
Vcollection.ScrollIndicatorInsets = UIEdgeInsets.Zero;
Vcollection.ContentOffset = new CGPoint(0f, 0f);
this.AutomaticallyAdjustsScrollViewInsets = false;
This is my code where I tried to rectify the issue, but to no avail. How can I remove this padding?
------------------EDIT ---------------------
Replacing the last 4 lines with
VehicleCollectionView.ContentInset = new UIEdgeInsets(0, -20, 0, 0);
VehicleCollectionView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Never;
Works, however pagination is still off. attempting to scroll through the collectionview shows huge offsets as shown below where pagination is stuck between 2 items
In your ViewDidLoad() method you can try two write this code
collectionView.ContentInset = new UIEdgeInsets (10, 10, 10, 10);
//collectionView.SectionInset = new UIEdgeInsets (20, 20, 20, 20)

How to create a table with multiple columns in ios

I am a beginner in xamarin ios, I want to create a table with 3 columns and multiple rows, and the no of row is depends on the data coming from the API .How can I do this...
Please help me...
I want to create the table like this...
You can simulate drawing the chart by following steps.
Custom TableHeaderView with three black rectangle ,just need add three label with its black border.
Do the same work as step1 with TableViewCell, and then place a textfield in first rectangle, place a button and a label in second rectangle,place two button in third rectangle.
Sample Code
TableHeaderView
public class headerView : UIView
{
public headerView()
{
this.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, 50);
nfloat width = UIScreen.MainScreen.Bounds.Width / 3;
UILabel title = new UILabel();
title.Text = "Title";
title.TextColor = UIColor.Black;
title.TextAlignment = UITextAlignment.Center;
title.Font = UIFont.SystemFontOfSize(20);
title.Layer.BorderColor = UIColor.Black.CGColor;
title.Layer.BorderWidth = 1;
title.Frame = new CGRect(0, 0, width, 50);
this.Add(title);
UILabel File = new UILabel();
File.Text = "File";
File.TextColor = UIColor.Black;
File.TextAlignment = UITextAlignment.Center;
File.Font = UIFont.SystemFontOfSize(20);
File.Layer.BorderColor = UIColor.Black.CGColor;
File.Layer.BorderWidth = 1;
File.Frame = new CGRect(width, 0, UIScreen.MainScreen.Bounds.Width / 3, 50);
this.Add(File);
UILabel Option = new UILabel();
Option.Text = "Option";
Option.TextColor = UIColor.Black;
Option.TextAlignment = UITextAlignment.Center;
Option.Font = UIFont.SystemFontOfSize(20);
Option.Layer.BorderColor = UIColor.Black.CGColor;
Option.Layer.BorderWidth = 1;
Option.Frame = new CGRect(width * 2, 0, UIScreen.MainScreen.Bounds.Width / 3, 50);
this.Add(Option);
}
}
table.TableHeaderView = new headerView();
TableViewCell
public CustomVegeCell (NSString cellId) : base (UITableViewCellStyle.Default, cellId)
{
SelectionStyle = UITableViewCellSelectionStyle.Gray;
nfloat width = UIScreen.MainScreen.Bounds.Width / 3;
UIView headingLabel = new UIView();
headingLabel.Layer.BorderColor = UIColor.Black.CGColor;
headingLabel.Layer.BorderWidth = 1;
headingLabel.Frame = new CGRect(0, 0, width, 100);
UIView subheadingLabel = new UIView();
subheadingLabel.Layer.BorderColor = UIColor.Black.CGColor;
subheadingLabel.Layer.BorderWidth = 1;
subheadingLabel.Frame = new CGRect(width, 0, width, 100);
UIView imageView = new UIView();
imageView.Layer.BorderColor = UIColor.Black.CGColor;
imageView.Layer.BorderWidth = 1;
imageView.Frame = new CGRect(width *2, 0, width, 100);
ContentView.Add (headingLabel);
ContentView.Add (subheadingLabel);
ContentView.Add (imageView);
///add additional control here
}

Chart without Axis Lines

I'm trying to create chart programmatically. Here is code
static void Main(string[] args)
{
var xvals = new[]
{
new DateTime(2012, 4, 4),
new DateTime(2012, 4, 5),
new DateTime(2012, 4, 6),
new DateTime(2012, 4, 7)
};
var yvals = new[] { 1, 3, 7, 12 };
// create the chart
var chart = new Chart();
chart.Width = 600;
chart.Height = 350;
var chartArea = new ChartArea();
chartArea.AxisX.IsMarginVisible = false;
chartArea.AxisY.IsMarginVisible = false;
chartArea.AxisX.LabelStyle.Format = "dd";
chartArea.AxisX.MajorGrid.LineWidth = 0;
chartArea.AxisY.MajorGrid.LineWidth = 0;
chartArea.AxisY.LabelStyle.Font = new Font("Consolas", 8);
chartArea.AxisX.LabelStyle.Font = new Font("Consolas", 8);
chart.ChartAreas.Add(chartArea);
var series = new Series();
series.Name = "Series1";
series.ChartType = SeriesChartType.Line;
chart.Series.Add(series);
chart.Series["Series1"].Points.DataBindXY(xvals, yvals);
chart.SaveImage("chart.png", ChartImageFormat.Png);
}
I'm getting following output,
How can I remove Axis Lines both X and Y? So that my output will only the blue line.
chartArea.AxisY.LineWidth = 0;
chartArea.AxisX.LineWidth = 0;
chartArea.AxisX.LabelStyle.Enabled = false;
chartArea.AxisY.LabelStyle.Enabled = false;
chartArea.AxisX.MajorTickMark.Enabled = false;
chartArea.AxisY.MajorTickMark.Enabled = false;
Fixed my problem

Connect two UIElement with Arc

I have two UIElements(i.e. rectangles) in Canvas and their coordinates. How can I connect them with arc in code behind?
No need to get an exact hit on the rectangles (or other objects): make sure the Z ordering is correct. arc.SetValue(Canvas.ZIndex, -1) will push it to the background. If you want a perpendicular hit, you'll need to break out the algebra :/
For the arc: (see http://msdn.microsoft.com/en-us/library/ms751808.aspx), it needs to be contained in a PathFigure.
Edit: this shows two connected rectangles. The line simple runs between the two centers. The arc starts on one center (the pathFigure startpoint), first argument is the center of the second object.
r1 = new Rectangle();
r1.Margin = new Thickness(50, 50, 0, 0);
r1.VerticalAlignment = System.Windows.VerticalAlignment.Top;
r1.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
r1.Height = 50;
r1.Width= 50;
r1.Fill = new SolidColorBrush(Colors.Red);
r2 = new Rectangle();
r2.Width = 50;
r2.Height = 50;
r2.Fill = new SolidColorBrush(Colors.Blue);
r2.Margin = new Thickness(350, 450, 0, 0);
r2.VerticalAlignment = System.Windows.VerticalAlignment.Top;
r2.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
l = new Line();
l.X1 = 75;
l.Y1 = 75;
l.X2 = 375;
l.Y2 = 475;
l.Fill = new SolidColorBrush(Colors.Purple);
l.Stroke = new SolidColorBrush(Colors.Purple);
l.StrokeThickness = 2;
l.SetValue(Canvas.ZIndexProperty, -1);
PathGeometry myPathGeometry = new PathGeometry();
// Create a figure.
PathFigure pathFigure1 = new PathFigure();
pathFigure1.StartPoint = new Point(75, 75);
pathFigure1.Segments.Add(
new ArcSegment(
new Point(375, 475),
new Size(50, 50),
45,
true, /* IsLargeArc */
SweepDirection.Clockwise,
true /* IsStroked */ ));
myPathGeometry.Figures.Add(pathFigure1);
// Display the PathGeometry.
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
myPath.SetValue(Canvas.ZIndexProperty, -1);
LayoutRoot.Children.Add(r1);
LayoutRoot.Children.Add(r2);
LayoutRoot.Children.Add(l);
LayoutRoot.Children.Add(myPath);

SlimDX 11 Depth Buffer issues

I am getting an issue with SlimDX March SDK (For DXSDK11 June 2010 I believe). The problem is that whenever I turn the attach the depth view to the output merger state I don't get any output on the screen. I have compared my code with DX11 samples and it does seem to be correct. I have tried all sorts of flags and formats for the depth test (including always passing etc.) but nothing seems to work. I'd appreciate if anyone can spot a mistake. Here is the code. Here are the steps:
Initialize the back buffer:
D3DDevice device;
SwapChain swapChain;
/// Create the swap chain
SwapChainDescription desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription
{
Width = ContextSettings.Width,
Height = ContextSettings.Height,
RefreshRate = new SlimDX.Rational(ContextSettings.RefreshRate, 1),
Format = ContextSettings.BufferFormat,
},
IsWindowed = !ContextSettings.FullScreen,
OutputHandle = WindowHandle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput,
};
FeatureLevel[] featureLevels = new FeatureLevel[] { FeatureLevel.Level_11_0, FeatureLevel.Level_10_1 };
DriverType driverType = DriverType.Hardware;
D3DDevice.CreateWithSwapChain(driverType, DeviceCreationFlags.Debug, featureLevels, desc, out device, out swapChain);
Device = device;
SwapChain = swapChain;
/// Setup window association
Factory factory = swapChain.GetParent<Factory>();
factory.SetWindowAssociation(WindowHandle, WindowAssociationFlags.IgnoreAll);
/// Setup back buffers and render target views
RenderBuffer = DXTexture2D.FromSwapChain<DXTexture2D>(swapChain, 0);
RenderView = new RenderTargetView(Device, RenderBuffer);
Then initialize the depth buffer:
Format depthFormat = Format.D32_Float;
Texture2DDescription depthBufferDesc = new Texture2DDescription
{
ArraySize = 1,
BindFlags = BindFlags.DepthStencil,
CpuAccessFlags = CpuAccessFlags.None,
Format = depthFormat,
Height = width,
Width = height,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription( 1, 0 ),
Usage = ResourceUsage.Default
};
DepthBuffer = new DXTexture2D(Device, depthBufferDesc);
DepthStencilViewDescription dsViewDesc = new DepthStencilViewDescription
{
ArraySize = 0,
Format = depthFormat,
Dimension = DepthStencilViewDimension.Texture2D,
MipSlice = 0,
Flags = 0,
FirstArraySlice = 0
};
DepthView = new DepthStencilView(Device, DepthBuffer, dsViewDesc);
DepthStencilStateDescription dsStateDesc = new DepthStencilStateDescription()
{
IsDepthEnabled = true,
IsStencilEnabled = false,
DepthWriteMask = DepthWriteMask.All,
DepthComparison = Comparison.Less,
};
DepthState = DepthStencilState.FromDescription(Device, dsStateDesc);
Setup the render targets:
DeviceContext.OutputMerger.DepthStencilState = DepthState;
DeviceContext.OutputMerger.SetTargets(DepthView, RenderView);
DeviceContext.Rasterizer.SetViewports(new Viewport(0, 0, ContextSettings.Width, ContextSettings.Height, 0.0f, 1.0f));
Clear();
As soon as I remove DepthView from OutputMerger.SetTargets I start seeing images on the screen (without the depth test of course) and vice-versa otherwise.
It turned out that in the depthBufferDesc, I was passing width to the Height variable and height to the Width. This was creating the two render targets with different dimensions which was breaking it down.

Categories