【问题标题】:Adding icons in DataGrid在 DataGrid 中添加图标
【发布时间】:2010-05-12 19:09:38
【问题描述】:

有没有办法在 c# 中为 DataGrid 中的每一行放置图标?

【问题讨论】:

  • 什么样的DataGrid?赢表格? ASP.NET?

标签: c# datagrid icons


【解决方案1】:

在 WinForms 上,您可以添加 DataGridViewImageColumn 并使用每行的图像填充它。

【讨论】:

  • 好的,我可以只隐藏 DataGridViewImageColumn 的 ColumnHeader 吗?
  • 您不能完全隐藏列标题,但您可以将标题文本设置为空字符串并将列的大小设置为 AllCells。这基本上会将列的大小缩小到最大图像的尺寸。
【解决方案2】:

我将假设 ASP.Net。这是一个带有图像按钮的示例。如果您能提供更多信息,可以提供更好的答案。

<asp:GridView ID="gridView1" runat="server">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:ImageButton ID="imageButton1" runat="server" ImageUrl="some_image.jpg" /></ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-12
    • 1970-01-01
    • 1970-01-01
    • 2011-07-05
    • 2015-12-27
    • 2013-07-30
    • 1970-01-01
    • 2015-10-29
    相关资源
    最近更新 更多