Example #1
0
        private void GridEX1_CurrentLayoutChanged(object sender, EventArgs e)
        {
            //clear the DataTable used by the previous layout
            jsNorthWindDataSet1.Clear();

            //When layouts are persisted into a file,
            //the DataSource and DataMember properties are
            //not persisted so you must reset them at run time
            //instead of resseting the DataSource and DataMember
            //properties when the layout is made, this could be done
            //in all the layouts at once in the LayoutLoad event
            if (GridEX1.CurrentLayout != null)
            {
                switch (GridEX1.CurrentLayout.Key)
                {
                case "Customers":
                    customersTableAdapter1.Fill(jsNorthWindDataSet1.Customers);
                    GridEX1.SetDataBinding(jsNorthWindDataSet1, "Customers");
                    break;

                case "Products":
                    productsTableAdapter1.Fill(jsNorthWindDataSet1.Products);
                    GridEX1.SetDataBinding(jsNorthWindDataSet1, "Products");
                    break;

                case "Suppliers":
                    suppliersTableAdapter1.Fill(jsNorthWindDataSet1.Suppliers);
                    GridEX1.SetDataBinding(jsNorthWindDataSet1, "Suppliers");
                    break;
                }
            }
        }
Example #2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            DialogResult result;
            string       layoutDir;
            FileStream   layoutStream;

            result = MessageBox.Show("Do you want to preserve the changes in " +
                                     "the GridEX control layout?", "Preserve changes",
                                     MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                e.Cancel = true;
            }
            else if (result == System.Windows.Forms.DialogResult.Yes)
            {
                DirectoryInfo dInfo;
                dInfo = new DirectoryInfo(Application.ExecutablePath).Parent;
                dInfo = new DirectoryInfo(dInfo.FullName + @"\LayoutData");
                if (!dInfo.Exists)
                {
                    dInfo.Create();
                }
                layoutDir    = dInfo.FullName + @"\GridEXLayout.gxl";
                layoutStream = new FileStream(layoutDir, FileMode.Create);
                GridEX1.SaveLayoutFile(layoutStream);
                layoutStream.Close();
            }
        }
Example #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            GridEXRow[] checkedRows;

            //get an array with all the rows that the user checked.
            checkedRows = GridEX1.GetCheckedRows();
            //if the user didn't check any row, you will get an empty array
            if (checkedRows.Length == 0)
            {
                MessageBox.Show("Select at least 1 message to be deleted.");
            }
            else
            {
                string message;
                message = String.Format("You are about to delete {0} message(s)." +
                                        "\n\rDo you want to continue?", checkedRows.Length);
                if (MessageBox.Show(message, "Janus Tutorial", MessageBoxButtons.YesNo) ==
                    System.Windows.Forms.DialogResult.Yes)
                {
                    foreach (GridEXRow row in checkedRows)
                    {
                        ((DataRowView)row.DataRow).Delete();
                    }
                }
            }
        }
Example #4
0
        private void LoadLayout()
        {
            string layoutDir = GetLayoutDirectory() + @"\GridEXLayout.gxl";

            if (FileExists(layoutDir))
            {
                FileStream layoutStream;
                layoutStream = new FileStream(layoutDir, FileMode.Open);
                GridEX1.LoadLayoutFile(layoutStream);
                layoutStream.Close();
            }
        }
Example #5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            //Creating the collection
            people = new PersonCollection();
            people.Add(new Person("Mr.", "John", "Smith", "Sr."));
            people.Add(new Person("Mrs.", "Mary", "Jones", ""));
            people.Add(new Person("Miss", "Sally", "Porter", ""));
            people.Add(new Person("Mr.", "Joseph", "Gold", "Jr."));
            people.Add(new Person("Dr.", "Ian", "Goldsmith", ""));

            //Binding GridEX to the people collection
            GridEX1.SetDataBinding(people, "");
            //Forcing GridEX control to generate the columns needed
            //to display all the properties in the Person class.
            GridEX1.RetrieveStructure();
        }
Example #6
0
		private void CreateDataSourceAndBindGrid()
		{
			gridDataSource = new DataSet();
			DataTable dataTable = new DataTable("Tasks");
			DataColumn column = dataTable.Columns.Add("Id", typeof(int));
			column.AutoIncrement = true;
			dataTable.Columns.Add("Subject", typeof(string));
			dataTable.Columns.Add("Complete", typeof(bool));
			dataTable.Columns.Add("DueDate", typeof(DateTime));

			//add datatable to dataset
			gridDataSource.Tables.Add(dataTable);
			//adding some sample rows
			dataTable.Rows.Add(1, "Task 1", false, DateTime.Today.AddDays(2));
			dataTable.Rows.Add(2, "Task 2", true, DateTime.Today);

			//bind grid to the datasource
			GridEX1.SetDataBinding(gridDataSource, "Tasks");

		}
Example #7
0
        private void BindGridEXControl()
        {
            DataSet   ds    = new DataSet();
            DataTable table = new DataTable("Messages");

            table.Columns.Add(new DataColumn("From", typeof(string)));
            table.Columns.Add(new DataColumn("Subject", typeof(string)));
            table.Columns.Add(new DataColumn("Date", typeof(DateTime)));

            ds.Tables.Add(table);

            table.Rows.Add("*****@*****.**", "Greetings", new DateTime(2002, 2, 5));
            table.Rows.Add("*****@*****.**", "Invitation", new DateTime(2002, 2, 7));
            table.Rows.Add("*****@*****.**", "A question", new DateTime(2002, 2, 10));
            table.Rows.Add("*****@*****.**", "How are you?", new DateTime(2002, 2, 12));
            table.Rows.Add("*****@*****.**", "Greetings", new DateTime(2002, 2, 14));
            table.Rows.Add("*****@*****.**", "Hi", new DateTime(2002, 2, 18));
            table.Rows.Add("*****@*****.**", "No Subject", new DateTime(2002, 2, 20));
            GridEX1.SetDataBinding(ds, "Messages");
        }