protected void ReadFromXData(agsXMPP.protocol.x.data.Data data )
        {
            DataTable table = new SearchResult( data.Reported, data.GetItems() ) ;
            _listView.DataContext = table ;

            XDataSearchResultHeader gridView = new XDataSearchResultHeader( data.Reported ) ;
            _listView.View = gridView ;

            Binding bind = new Binding() ;
            _listView.DataContext = table ;
            _listView.SetBinding( ListView.ItemsSourceProperty, bind ) ;
        }
예제 #2
0
파일: frmSearch.cs 프로젝트: phiree/dzdocs
        /// <summary>
        /// Shows the search result in the UI
        /// </summary>
        /// <param name="xdata"></param>
        private void ShowData(agsXMPP.protocol.x.data.Data xdata)
        {
            lock (this)
            {
                //ClearGridAndDataTable();

                dataGridView1.SuspendLayout();

                _dataTable.Rows.Clear();
                _dataTable.Columns.Clear();
                dataGridView1.Columns.Clear();

                agsXMPP.protocol.x.data.Reported reported = xdata.Reported;
                if (reported != null)
                {
                    foreach (agsXMPP.protocol.x.data.Field f in reported.GetFields())
                    {
                        // Create header
                        DataGridViewTextBoxColumn header = new DataGridViewTextBoxColumn();
                        header.DataPropertyName = f.Var;
                        header.HeaderText = f.Label;
                        header.Name = f.Var;

                        dataGridView1.Columns.Add(header);

                        // Create dataTable Col
                        _dataTable.Columns.Add(f.Var, typeof(string));
                    }
                }

                agsXMPP.protocol.x.data.Item[] items = xdata.GetItems();
                foreach (agsXMPP.protocol.x.data.Item item in items)
                {
                    DataRow dataRow = _dataTable.Rows.Add();
                    foreach (agsXMPP.protocol.x.data.Field field in item.GetFields())
                    {
                        dataRow[field.Var] = field.GetValue();
                    }
                }

                if (_dataTable.Rows.Count == 0)
                    toolStripStatusLabel1.Text = "no items found";
                else
                    toolStripStatusLabel1.Text = String.Format("{0} items found", _dataTable.Rows.Count.ToString());

                dataGridView1.ResumeLayout();
            }
        }