繁体   English   中英

如何从右向左更改datagridview的一列方向?

[英]How to change direction of one column of datagridview from right to left?

我在asp.net datagrid视图中有以下代码:

<asp:GridView ID="gvStore" runat="server" AllowPaging="True" AllowSorting="True"
                            AutoGenerateColumns="False" CellPadding="4" EmptyDataText="هیچ کالایی موجود نیست"
                            Font-Names="Tahoma" Font-Size="Small" ForeColor="#333333" HorizontalAlign="Center"
                            Width="1000px" OnRowDataBound="gvStore_RowDataBound" OnSelectedIndexChanging="gvStore_SelectedIndexChanging" 
                            OnPageIndexChanging="gvStore_PageIndexChanging" CaptionAlign="Right" DataKeyNames="store_id"> 
                            <PagerSettings FirstPageText="ابتدا" LastPageText="انتها" Mode="NumericFirstLast"
                                NextPageText="بعدی" PreviousPageText="قبلی" />
                            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                            <Columns>
                                <asp:BoundField DataField="rownum" HeaderText="ردیف" />
                                <asp:BoundField DataField="store_id" HeaderText="شناسه" Visible="False" />
                                <asp:BoundField DataField="groups_name" HeaderText="نام کالا"></asp:BoundField>
                                <asp:BoundField DataField="str" HeaderText="مشخصات کالا"></asp:BoundField>
                                <asp:BoundField DataField="plaque_no1" HeaderText="شماره اموال 1"></asp:BoundField>
                                <asp:BoundField DataField="plaque_no2" HeaderText="شماره اموال 2"></asp:BoundField>
                                <asp:BoundField DataField="buy_request_no" HeaderText="شماره درخواست" ></asp:BoundField>
                                <asp:BoundField DataField="contract_no" HeaderText="شماره قرارداد"></asp:BoundField>
                                <asp:BoundField HeaderText="تاریخ ورود" DataField="bdate"></asp:BoundField>
                                <asp:BoundField HeaderText="محل بودجه" DataField="budjet_name"></asp:BoundField>
                                <asp:CommandField SelectText="جزئیات درخواست" ShowSelectButton="True" />
                            </Columns>
                            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                            <HeaderStyle BackColor="#990000" Font-Bold="False" Font-Size="Small" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>

如何从右到左更改此一列的方向? 有人可以帮我吗?

您可以使用下面的按钮从右向左更改文本方向。

GridView1.Style[HtmlTextWriterStyle.Direction] = "rtl";

特殊细胞

GridView1.Rows[0].Cells[1].Style[HtmlTextWriterStyle.Direction] = "rtl"; 

从左到右

GridView1.Style[HtmlTextWriterStyle.Direction] = "ltr";

GridView1.Rows[0].Cells[1].Style[HtmlTextWriterStyle.Direction] = "ltr";

是完整参考的链接。

我正在使用此css

css救救我:

.gridalign
{
   width:auto;
   text-align:right;
   direction:ltr;

   padding-right:15px;
   padding-left:15px;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM