예제 #1
0
        public void Save(GridEX grid, IGridLayoutKey key)
        {
            Stream stream = new FileStream(LayoutFileName(key), FileMode.Create);

            grid.SaveLayoutFile(stream);
            stream.Close();
        }
예제 #2
0
파일: frmGroupBy.cs 프로젝트: mwilian/demos
		public DialogResult ShowDialog(GridEX grid, Form parent)
		{

			MemoryStream layoutStream = new MemoryStream();

			grid.SaveLayoutFile(layoutStream);
			layoutStream.Flush();
			layoutStream.Position = 0;

			this.bufferGrid = new GridEX();
			this.bufferGrid.LoadLayoutFile(layoutStream);

			//Set the DataBinding of the Grid and DropDowns in order to be able to retrieve
			//the ValueList of the columns used in the FilterEditor
			this.bufferGrid.BindingContext = this.BindingContext;
			this.bufferGrid.SetDataBinding(grid.DataSource, grid.DataMember);
			this.bufferGrid.ImageList = grid.ImageList;

            for (int i = 0; i < grid.DropDowns.Count; i++)
			{
				GridEXDropDown ddMain = grid.DropDowns[i];
				GridEXDropDown ddBuffer = bufferGrid.DropDowns[i];
				ddBuffer.SetDataBinding(ddMain.DataSource, ddMain.DataMember);

			}

			layoutStream.Dispose();

			this.Table = bufferGrid.RootTable;
			this.FillTablesCombo();
			this.FillHierarchicalGroupModeCombo();

			if (bufferGrid.GroupMode == GroupMode.Collapsed)
			{
				this.UiCommandManager1.Commands["cmdExpand"].IsChecked = false;
				this.UiCommandManager1.Commands["cmdExpand"].Text = "All collapsed";
			}

			this.ShowDialog(parent);


			if (this.DialogResult == System.Windows.Forms.DialogResult.OK)
			{

                if (!this.CreateGroups())
                {
                    return this.DialogResult;
                }

				layoutStream = new MemoryStream();
				this.bufferGrid.SaveLayoutFile(layoutStream);

				layoutStream.Flush();
				layoutStream.Position = 0;

				grid.LoadLayoutFile(layoutStream);

                for (int i = 0; i < grid.DropDowns.Count; i++)
				{
					GridEXDropDown ddMain = grid.DropDowns[i];
					GridEXDropDown ddBuffer = bufferGrid.DropDowns[i];
					ddMain.SetDataBinding(ddBuffer.DataSource, ddBuffer.DataMember);
				}
				grid.Refetch();
			}
			return this.DialogResult;
		}