GridView SubItem [英] GridView SubItem

查看:57
本文介绍了GridView SubItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我正在尝试在WinForms中使用网格视图,当我想为项目添加折扣时,折扣应列在该项目下方。这对我来说有点复杂,我知道我们可以添加另一列来获得折扣,但现在
有人希望我在该项目下面有折扣。 

Hi everyone. I'm trying to use a grid view in WinForms that when i want to add a discount to an item, the discount should be listed below that item. This is kinda complicated for me, i know we can add another column to have the discount in there but now someone wants me to have the discount below the item. 

任何帮助将不胜感激。

问候

推荐答案

你好,

 在填充GridView行时,让代码检查项目为折扣,然后

 As you populate the GridView rows, have the code check for item as discount then

添加新行折扣数据。 如果item不是折扣,那么将正常的

add the new row with discount data.  If item is not as discount then add the normal

数据添加到该行并继续填充网格。 实现这一点将取决于

data to the row and continue populating the grid.  To implement this will depend

对存储每个项目信息的方式。

greatly on the way you store information about each item.

 

  示例

class Item
{
    // Base variables
    //
    public int Quanity { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }
    // easy to calc percentage
    // value of zero = no disount
    public decimal Discount { get; set; }
}

 当您的代码插入新的行数据时,Discount的值确定

 When your code inserts new row data, the value of Discount determines if

是否需要额外的行用于显示Discount变量。 

an extra row is used to display the Discount variable. 

 

 如何实施数据库以及项目数据的结构将有所帮助

 How you implement your database and the structure of item data will help

提供更精确的解决方案。以上是基本的框架工作。

to give a more precise solution. The above is a basic frame work.

 希望这会有所帮助:)

 Hope this helps :)


这篇关于GridView SubItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆