Beispiel #1
0
        private void LoadData()
        {
            TreeBLL treeBLL = new TreeBLL();

            dtTree = treeBLL.gettAllTree();

            dgvShopping.DataSource = getTable(dtTree);
        }
        private void LoadData()
        {
            dtTree     = new DataTable();
            dtCategory = new DataTable();

            // get data for 2 table
            TreeBLL treeBLL = new TreeBLL();

            dtTree = treeBLL.gettAllTree();
            CategoryBLL categoryBLL = new CategoryBLL();

            dtCategory = categoryBLL.getAll();

            //Khai bao cot BookID la khoa chinh
            dtTree.PrimaryKey = new DataColumn[] { dtTree.Columns[0] };

            //binding to ComboBox : complex binding
            cbCatageryName.DataSource    = dtCategory;
            cbCatageryName.DisplayMember = "Category";
            cbCatageryName.ValueMember   = "ID";

            //Binding GridView voi ComboBox
            cbCatageryName.DataBindings.Clear();
            cbCatageryName.DataBindings.Add("SelectedValue", dtTree, "CategoryID");

            //binding to DataGridView : Complex Binding
            dgvTree.DataSource = dtTree;

            //Binding to TextBoxes: Simple Binding
            txtName.DataBindings.Clear();
            txtPrice.DataBindings.Clear();
            txtQuantity.DataBindings.Clear();
            txtDescription.DataBindings.Clear();

            // Picture box duoc bat su kien o cellClick cua dgvTree


            txtDescription.DataBindings.Add("Text", dtTree, "Description");
            txtName.DataBindings.Add("Text", dtTree, "Name");
            txtPrice.DataBindings.Add("Text", dtTree, "Price");
            txtQuantity.DataBindings.Add("Text", dtTree, "Quantity");
        }