Beispiel #1
0
        private void loadGrid()
        {
            dataGridView1.AutoGenerateColumns = false;

            DataTable dt = new DataTable();

            dt.Columns.Add("Title", typeof(String));
            dt.Columns.Add("Document name", typeof(String));
            dt.Columns.Add("Start page", typeof(String));
            dt.Columns.Add("End page", typeof(String));

            DataGridViewTextBoxColumn startPage = new DataGridViewTextBoxColumn();

            startPage.Width            = 70;
            startPage.HeaderText       = "Start Page";
            startPage.DataPropertyName = "Start Page";

            DataGridViewTextBoxColumn endPage = new DataGridViewTextBoxColumn();

            endPage.Width            = 70;
            endPage.HeaderText       = "End Page";
            endPage.DataPropertyName = "End Page";

            DataGridViewComboBoxColumn documentName = new DataGridViewComboBoxColumn();
            DataTable dtList = SQLiteDatabaseCommand.dataList("tblDocument");

            dtList.Columns.Remove(dtList.Columns[0]);
            dtList.Columns.Remove(dtList.Columns[1]);
            int           x     = 0;
            List <string> items = new List <string>();

            foreach (DataRow row in dtList.Rows)
            {
                items.Add(dtList.Rows[x][0].ToString());
                x++;
            }
            documentName.DataSource       = items;
            documentName.Width            = 200;
            documentName.HeaderText       = "Document Name";
            documentName.DataPropertyName = "DocumentName";

            DataGridViewTextBoxColumn title = new DataGridViewTextBoxColumn();

            title.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            title.HeaderText       = "Title";
            title.DataPropertyName = "Title";

            dataGridView1.DataSource = dt;
            dataGridView1.Columns.AddRange(title, documentName, startPage, endPage);
        }
Beispiel #2
0
 private void loadData()
 {
     try
     {
         DataTable dt = SQLiteDatabaseCommand.dataList("tblDocument");
         dt.Columns.Remove(dt.Columns[0]);
         dt.Columns.Remove(dt.Columns[1]);
         dataGridView1.DataSource = dt;
     }
     finally
     {
         dataGridView1.Refresh();
     }
 }