如何从右到左打印datagridview [英] how to print datagridview from right to left
本文介绍了如何从右到左打印datagridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨所有
i想要从右到左打印datagridview
互联网打印datagridview中的大多数课程从左到右
i尝试制作RightToLeft属性为Yes但没有更改,datagridview从左到右打印
任何人都可以帮助我
谢谢
解决方案
如果你不能这样做的话。我将向您发送从右到左打印的完整代码
1-替换使用此代码绘制列的代码。
< span class =code-comment> // 绘制列
( int i = GridViewID.Columns.Count - 1 ; i > = 0 ; i--)
{
e.Graphics.FillRectangle( new SolidBrush(Color.LightGray),
new Rectangle(( int )arrColumnLefts [iCount],iTopMargin,
( int )arrColumnWidths [iCount],iHeaderHeight));
e.Graphics.DrawRectangle(Pens.Black,
new Rectangle(( int )arrColumnLefts [iCount],iTopMargin,
( int )arrColumnWidths [iCount],iHeaderHeight));
e.Graphics.DrawString( + GridViewID.Columns [i ] .HeaderText,GridViewID.Columns [i] .InheritedStyle.Font,
new SolidBrush(GridViewID.Columns [i] .InheritedStyle.ForeColor),
new RectangleF(( int )arrColumnLefts [iCount],iTopMargin,
( int )arrColumnWidths [iCount],iHeaderHeight),strFormat);
iCount ++;
}
2-用这段代码替换绘制单元格的代码
// 绘制列内容
for ( int i = GridRow.Cells.Count - 1 ; i > = 0 ; i--)
{
if (GridRow.Cells [i] .Value!= null )
{
e.Graphics.DrawString( + GridRow.Cells [i] .Value.ToString(),GridRow.Cells [i] .InheritedStyle.Font,
new SolidBrush(GridRow.Cells [i] .InheritedStyle.ForeColor),
new RectangleF(( int )arrColumnLefts [iCount],( float )iTopMargin,
( int )arrColumnWidths [iCount],( float )iCellHeight),strFormat);
}
// 绘制单元格边框
e.Graphics。 DrawRectangle(Pens.Black, new Rectangle(( int )arrColumnLefts [iCount],
iTopMargin ,( int )arrColumnWidths [iCount],iCellHeight));
iCount ++;
}
希望对您有所帮助。
问候,
A.Mandour
认为你可以设置Flowdirection =RightToLeft:
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid。 aspx [ ^ ]
但你可能需要修复单个单元格上的对齐:
http://stackoverflow.com/questions/4177668/changing-flowdirection-of-a-cell-in- wpfs-datagrid [ ^ ]
这可以帮到你...
点击这里
hi all
i want to print datagridview from right to left
most classes in internet print datagridview from left to right
i try to make RightToLeft property to Yes but no change and datagridview printed from left to right
can any one help me
thanks解决方案Hi,
if you couldn't do it . i will send you my complete code that printing from right to left
1- replace the code that drawing columns with this code.
//Draw Columns for (int i = GridViewID.Columns.Count - 1; i >= 0; i--) { e.Graphics.FillRectangle(new SolidBrush(Color.LightGray), new Rectangle((int)arrColumnLefts[iCount], iTopMargin, (int)arrColumnWidths[iCount], iHeaderHeight)); e.Graphics.DrawRectangle(Pens.Black, new Rectangle((int)arrColumnLefts[iCount], iTopMargin, (int)arrColumnWidths[iCount], iHeaderHeight)); e.Graphics.DrawString(" " + GridViewID.Columns[i].HeaderText, GridViewID.Columns[i].InheritedStyle.Font, new SolidBrush(GridViewID.Columns[i].InheritedStyle.ForeColor), new RectangleF((int)arrColumnLefts[iCount], iTopMargin, (int)arrColumnWidths[iCount], iHeaderHeight), strFormat); iCount++; }
2- replace the code that drawing cells with this code
//Draw Columns Contents for (int i = GridRow.Cells.Count - 1; i >= 0; i--) { if (GridRow.Cells[i].Value != null) { e.Graphics.DrawString(" " + GridRow.Cells[i].Value.ToString(), GridRow.Cells[i].InheritedStyle.Font, new SolidBrush(GridRow.Cells[i].InheritedStyle.ForeColor), new RectangleF((int)arrColumnLefts[iCount], (float)iTopMargin, (int)arrColumnWidths[iCount], (float)iCellHeight), strFormat); } //Drawing Cells Borders e.Graphics.DrawRectangle(Pens.Black, new Rectangle((int)arrColumnLefts[iCount], iTopMargin, (int)arrColumnWidths[iCount], iCellHeight)); iCount++; }
Wish that could helps you.
Regards,
A.Mandour
Think you could just set the Flowdirection="RightToLeft":
http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.aspx[^]
But you proberbly need to fix the alignement on the individual cells:
http://stackoverflow.com/questions/4177668/changing-flowdirection-of-a-cell-in-wpfs-datagrid[^]
This may help you...
Click Here
这篇关于如何从右到左打印datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文