1

内部にコマンド ボタンがある DevExpress グリッドビューを使用しています。代わりに画像を使用したい。どうすればそれが可能になりますか?

今まで私はこれをたくさん試しました:

GridViewCommandColumn commancol = new GridViewCommandColumn(); 
commancol.ButtonType = ButtonType.Image; 
GridViewCommandColumnButton moveUpBtn; 
moveUpBtn.Image.Url = "~/App_Themes/Images/GridControl/grid-delete.png"; 
commancol.Add(moveUpBtn); 

しかし、それはエラーを出しています。

aspxページの代わりに.csページから下の方法ボタンを追加したい。だから私はコードビハインドから上記の方法を試しました。

<dx:GridViewCommandColumn ButtonType="Image">
            <HeaderTemplate>
            </HeaderTemplate>
            <DeleteButton Visible="true" Text="" Image-Url="grid-delete.png"
                Image-ToolTip="Delete Record">
            </DeleteButton>
        </dx:GridViewCommandColumn>

ありがとう

4

4 に答える 4

0

aspxページからではなく、コードbehindから以下のタイプの削除コマンドボタンを追加したいと思います。

<dx:GridViewCommandColumn ButtonType="Image">
                <HeaderTemplate>
                </HeaderTemplate>
                <DeleteButton Visible="true" Text="" Image-Url="grid-delete.png"
                    Image-ToolTip="Delete Record">
                </DeleteButton>
            </dx:GridViewCommandColumn>
于 2012-12-31T10:11:36.187 に答える
0

次のように使用できます。1) itemtemplate 宣言でimageButton 2) 宣言しcommandnamecommandargument 3) getimagepath を宣言します。 4) cs ページで getimage 関数を次のように宣言します。

     <asp:TemplateField HeaderText="Edit" ItemStyle-VerticalAlign="Top">
    <ItemTemplate>
   <asp:ImageButton ID="ibDelete" runat="server" CommandName="Delete" CommandArgument='<%# Bind("") %>'
                            ImageUrl='<%#GetImagePath("delete.png")%>' Width="20" Height="20" OnClick="ibDelete_Click"
                            OnClientClick='<%# Eval("", "return confirm(\"Are you sure to delete - {0} ?\");") %>'
                            ToolTip="Delete Item" />
    </ItemTemplate>




public string GetImagePath(string imgName)
        {
            string Finalurl =  this.TemplateSourceDirectory + "/images/" + imgName;
            return Finalurl;
        }

5) 行コマンドを次のように宣言します

protected void row_command(object sender, gridviewrowcommand e)
{
     if(e.commandname=="Delete")
      {
           if(e.commandargument!=null)
            {
                  // do the work here
            }
       }
}
于 2012-12-31T10:04:35.807 に答える
0

CommandColumnは以下のように簡単に追加できますが、asp.net ページ イベントが正しく機能するように注意する必要があります。

protected void Page_Init(object sender, EventArgs e)
{
    GridViewCommandColumn column = new GridViewCommandColumn("....");
    column.DeleteButton.Visible = true;
    column.DeleteButton.Image.Url = "set path here";
    column.Visible = true;
    column.VisibleIndex = 2;//place where you want it to display
    ASPxGridView1.Columns.Add(column); 
}
protected void Page_Load(object sender, EventArgs e)
{
   // Bind Data here
    BindData();
}

Command Columnsのドキュメントを参照すると、別のコマンド ボタンも取得して、必要に応じて実行時にそれらのプロパティを設定できます。

この助けを願っています..

于 2012-12-31T10:25:25.697 に答える
0
<dx:GridViewCommandColumn Name="deleteRow" ShowDeleteButton="True" VisibleIndex="3" ButtonType="Image">
                <CustomButtons>
                    <dx:GridViewCommandColumnCustomButton Visibility="AllDataRows" Image-Width="20" Image-Url="~/img/delete-icon.png"
                        Image-Height="20">
                        <Image Height="20px" Width="20px">
                        </Image>
                    </dx:GridViewCommandColumnCustomButton>
                </CustomButtons>
                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
            </dx:GridViewCommandColumn>
于 2015-08-13T06:52:23.370 に答える