I would like to modify the GroupByRow description to take up more than one line when printing.
Here is what I have tried:
private void uGridReport_InitializeGroupByRow(object sender, InitializeGroupByRowEventArgs e)
{
if (e.Row.Band.Layout.IsPrintLayout)
if (e.Row.ParentRow != null)
if (e.Row.Index != 0)
e.Row.StartsNewPrintedPage = true;
e.Row.Description = e.Row.ParentRow.Description + "\r\n" + e.Row.Description;
}
Any ideas?
The GroupByRow does not support multiline text. You should Submit a Feature Request and perhaps this functionality can be added in a future release.
The only way I can think of that you might be able to get it to work is if you increase the height of the row (by setting the Height property on the row) and then use a DrawFilter to draw the text yourself.
this.ultraGrid1.DrawFilter = new MyDrawFilter();
public class MyDrawFilter : IUIElementDrawFilter { bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { DependentTextUIElement dependentTextUIElement = drawParams.Element as DependentTextUIElement; if (null != dependentTextUIElement) { drawParams.DrawString(dependentTextUIElement.RectInsideBorders, dependentTextUIElement.Text, true, true); return true; } return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is DependentTextUIElement && drawParams.Element.Parent is GroupByRowDescriptionUIElement) { return DrawPhase.BeforeDrawForeground; } return DrawPhase.None; } }
Hi,
Mike is right. Here is small sample with this approach
Regards
Sample
If you need any additional assistance don’t hesitate to ask.
Georgi,
I was able to get the DrawFilter to work, however it doesn't look very good. Here is what I am trying to do. I am implementing page breaks on group by fields. If the page break is on the outer-most group by field, everything works perfectly. However it the page break is on a subordinate group-by field, the group by field is shown at the top of the page without the parent group for all group by values but the first one. I would like to show group by row description for each group by row that is above the one in which the page break is being applied. I have looked at the CreationFilter, but have been unable to get that to work. Do you have any suggestions?
Currie
Hi Currie,
When you say "page breaks" are you talking about some kind of paging of the data on-screen? Or are you talking about printing? If you mean printing, then the latest version of the UltraGrid supports page breaks on a row and so you might want to update to the latest version if you don't already have it, so you can take advantage of that functionality.
I read your explanation of what you are trying to do half a dozen times, but I'm afraid I am just not getting it. Maybe you could explain in more detail or include a screen shot with a mockup of what you want?
You can't use a CreationFilter to change the size of an object, though. So if you are trying to use a CreationFilter to make the rows bigger, that won't work You would have to make the rows taller using the Height property on the row and then you would be able to use a CreationFilter or DrawFilter to draw into the extra space.
My apologies Mike. The original post states that this was in a printing application, I should have made that more clear. I do have the latest version and I have implemented the page breaks. I have uploaded 2 sample pdf files that illustrate what I want to do. The reporting scenario is that I have 2 Group By fields, Branch and IGL Code. The page break occurs on IGL code. Group By Sample 1.pdf was created by printing the Grid to a pdf print driver. If we are processing the outer level group by row (Branch), we check to see if a subordinate group by row has a page break, and if so, we do the break on the outer group by row so that both values are on the same page. Then when we process the inner group by rows, those values are on a page by themselves. You can see that on page 2 of Sample 1, where IGL Code 1 is on a page by itself. The problem is that there is no context for that, i.e., you don't know what branch it is with unless you have the other page. We have found that many of our customers want to run a report like this, do page breaks on the group by fields, and then distribute each page (or pages) to different groups.
The second sample shows how we want this to look. This sample was created by exporting the grid to pdf. (We have our own pdf export routine we have written). You can see on page 2 that the branch and the igl code are printed on all pages.
Based on Georgi's post earlier, i had put a line break in the description on the Igl Code group by row, but the printed output looked much different than the output generated for the first group. The Group By Sample 3.pdf file shows the result from that.
Thank you for any assistance you may offer.
H Currie,
I'm looking at Sample 3.pdf and I'm trying to understand what's wrong with it. You say the printer output looks a lot different, but the differences seem very subtle to me. I'm not seeing any big difference.
The indentation of the row is a little different, since the child GroupByRow row level is indented. And the spacing between the Branch and IGL Code text in the description is a little different. But it's a very small difference.
If you are exporting the grid to PDF using our PDF engine, and the PDF document is exactly what you want, then it seems to me that the easiest solution here is for you to simply export to PDF and print the PDF.
There's a sample included with NetAdvantage that demonstrates how to print a report. The sample is called DocumentExporterGallery and there's a button on the sample that says "Printing" which you can click to print a report in memory directly to the printer. But basically, the code looks like this:
// Print the Report PrintDialog pd = new PrintDialog(); if (pd.ShowDialog() == DialogResult.OK) report.Print(pd.PrinterSettings.PrinterName);
If that's no good, for whatever reason, then the alternative would be a very complex and difficult CreationFilter to try to rearrange the elements in the grid into a form that you want. I'm not sure that's something we could help you with, since it's not like a quick sample we could whip up, it's probably several days work.