【问题标题】:Add picture into GridViewImageColumn将图片添加到 GridView 图像列
【发布时间】:2014-08-08 10:09:01
【问题描述】:

我尝试将图片添加到我的GridViewImageColumn 并找到this 教程

这是我的代码(来自上面的链接):

GridViewImageColumn imageColumn = new GridViewImageColumn();
imageColumn.Name = "ImageColumn";
imageColumn.FieldName = "Photo";
imageColumn.HeaderText = "Picture";
imageColumn.ImageLayout = ImageLayout.Zoom;           
radGridView1.MasterTemplate.Columns.Insert(4, imageColumn);

所以我的问题是我需要在哪里指定我的图像路径?

【问题讨论】:

    标签: c# .net telerik radgridview


    【解决方案1】:

    试试这个

    收起 imageGridImageColumn

    GridImageColumn 中的每个单元格都包含一个图像。要指定该图像的图像 URL,您可以执行以下操作之一:

    Set the ImageUrl property to a static value. When you use this method, every image appears the same in the entire column.
    
    Set the DataImageUrlFields property to a field in the source that can be used to supply the image path and format it by setting the DataImageUrlFormatString property. You can specify multiple fields if the image URL is determined by more than one field in the database.
    
    Set the DataAlternateTextField property to specify by which field in the grid source the column will be sorted/filtered. For the filtering, you must also explicitly set the DataType property of the column to the type of the field specified through the DataAlternateTextField property (System.String in the common case). You can also apply formatting using the DataAlternateTextFormatString property. 
    

    [注意]注意

    请注意,如果您直接通过列的 SortExpression 属性指定排序表达式,它将具有更高的优先级,并会覆盖 DataAlternateTextField 属性的排序/过滤条件。

    该列的其他常用属性是 AlternateText、ImageAlign、ImageWidth、ImageHeight 等。以下示例显示了该产品在线演示中 GridImageColumn 的声明: 复制ASPX

    <telerik:GridImageColumn DataType="System.String" DataImageUrlFields="CustomerID"
      DataImageUrlFormatString="IMG/{0}.jpg" AlternateText="Customer image" DataAlternateTextField="ContactName"
      ImageAlign="Middle" ImageHeight="110px" ImageWidth="90px" HeaderText="Image Column"
      FooterText="ImageColumn footer">
    </telerik:GridImageColumn>
    

    【讨论】:

      【解决方案2】:

      您可以尝试使用 DataMemberBinding="{Binding [Image]}"。

      【讨论】:

        【解决方案3】:

        尝试在你的 .aspx 文件中实现类似的东西,看看效果如何......

        <telerikGridView:RadGridView.Columns>
        
         <telerikGridView:GridViewColumn UniqueName="img" Width="">
        
        <telerikGridView:GridViewColumn.CellTemplate>
          <DataTemplate>
            <Image Stretch="None" Source="../Images/MyImage.png" /> // just an example path
          </DataTemplate>
          </telerikGridView:GridViewColumn.CellTemplate>
        
         </telerikGridView:GridViewColumn>
        
        </telerikGridView:RadGridView.Columns>
        

        【讨论】:

        • 有机会获得 Winforms 示例吗?
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多