Пример #1
0
        private void UpdateOrderList()
        {
            try
            {
                OrderList.Columns[8].Text = refresh_ol_count++.ToString();
                var data_item = mOrderListDataSet.getItems();
                if (data_item != null)
                {
                    int top_index = (OrderList.TopItem != null) ? OrderList.TopItem.Index : -1;
                    OrderList.BeginUpdate();
                    OrderList.Items.Clear();
                    for (int i = 0; i < data_item.Length; i++)
                    {
                        ListViewItem view_item = new ListViewItem();
                        view_item.SubItems[0].Text = data_item[i].mOrderTime.ToString();
                        view_item.SubItems.Add(data_item[i].mStockCode);
                        view_item.SubItems.Add(data_item[i].mStockName);
                        view_item.SubItems.Add(data_item[i].mOrderPrice.ToString());
                        view_item.SubItems.Add(data_item[i].mOrderSize.ToString());
                        view_item.SubItems.Add(data_item[i].mOrderDirect);
                        if (data_item[i].mOrderDirect.Equals("买入担保品"))
                        {
                            view_item.ForeColor = Color.Red;
                        }
                        else if (data_item[i].mOrderDirect.Equals("卖出担保品") ||
                                 data_item[i].mOrderDirect.Equals("融券卖出"))
                        {
                            view_item.ForeColor = QuoteForm.RGB(0x65E339);
                        }

                        view_item.SubItems.Add(data_item[i].mOrderId);
                        view_item.SubItems.Add(data_item[i].mOrderStatus);
                        if (data_item[i].mOrderId.Equals(mOrderListDataSet.selected_id))
                        {
                            view_item.Selected = true;
                        }
                        if (mOrderListDataSet.checked_ids.Contains(data_item[i].mOrderId))
                        {
                            view_item.Checked = true;
                        }
                        OrderList.Items.Add(view_item);
                    }
                    OrderList.EndUpdate();
                    if (top_index > 0 && OrderList.Items.Count > top_index)
                    {
                        int H = OrderList.Height;
                        int h = OrderList.TopItem.GetBounds(ItemBoundsPortion.Entire).Height;
                        int n = H / h - 1;
                        if (n + top_index >= OrderList.Items.Count - 1)
                        {
                            OrderList.TopItem = OrderList.Items[top_index + 1];
                        }
                        else
                        {
                            OrderList.TopItem = OrderList.Items[top_index];
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }