注册 登录
编程论坛 WPF/Silverlight

WPF listView 的操作问题

一只茶叶 发布于 2014-03-19 22:13, 5572 次点击
只有本站会员才能查看附件,请 登录


如图,当输入条码后,ListView 中出现数据

但是,当我输入第二个条码后, ListView 只显示第二个条码的内容,第一个条码,被清空了。

listView 前台是这么写的:

 <ListView Grid.Column="1"
                      x:Name="lsList"                     
                      Grid.RowSpan="2"
                      Margin="10"  >
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="商品编号" Width="100"
                                        DisplayMemberBinding="{Binding Path=GoodsID}"/>
                        <GridViewColumn Header="商品名称" Width="100"
                                        DisplayMemberBinding="{Binding Path=GoodsName}"/>
                        <GridViewColumn Header="价钱" Width="50"
                                        DisplayMemberBinding="{Binding Path=Export_Price}"/>
                        <GridViewColumn Header="数量" Width="50" />
                    </GridView>
                </ListView.View>


            </ListView>


查询条码的后台,我是这么写的:

        /// <summary>
        /// 查询条码
        /// </summary>
        SqlDataAdapter sda;
        DataTable dt;
        public void SelectData(string sql)
        {
            try
            {
                string strcon = string.Format(@"Data Source=.\SQLExpress;Initial Catalog=SuperMarket2;Integrated Security=True");
                SqlConnection con = new SqlConnection(strcon);
                con.Open();
                sda = new SqlDataAdapter(sql, con);
                dt = new DataTable();
                sda.Fill(dt);
                lsList.ItemsSource = dt.DefaultView;
                con.Close();
            }
            catch (Exception msg)
            {               
               MessageBox.Show("出错"+msg.Message);
            }

        }

//  查询语句
 string sql_select = @"select GoodsID,GoodsName,Export_Price
                                 from    GoodsInfo
                                 where GoodsID='" + enterNum.Text + "'";

【求助】:  1.怎样才能实现,输入一个条码,listview 一条一条叠加??

                      2. 数量,查询语句里面木有写数量,数量列,我想实现的是:输入一次条码,数量默认为 :1

                          或者。。。将数量修改为一个可以调的数字的控件。。。

求各位老师指导一下。。。

感激不尽
0 回复
1