private void LoadCategorySample(string category, SourceGrid.Cells.Controllers.Button linkEvents, Type[] assemblyTypes, SourceGrid.Cells.Views.IView categoryView, SourceGrid.Cells.Views.IView headerView) { int row; //Create Category Row row = grid1.RowsCount; grid1.Rows.Insert(row); grid1[row, 0] = new SourceGrid.Cells.Cell(category); grid1[row, 0].View = categoryView; grid1[row, 0].ColumnSpan = grid1.ColumnsCount; //Create Headers row = grid1.RowsCount; grid1.Rows.Insert(row); SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("Sample N?"); header1.View = headerView; header1.AutomaticSortEnabled = false; grid1[row, 0] = header1; SourceGrid.Cells.ColumnHeader header2 = new SourceGrid.Cells.ColumnHeader("Description"); header2.View = headerView; header2.AutomaticSortEnabled = false; grid1[row, 1] = header2; //Create Data Cells for (int i = 0; i < assemblyTypes.Length; i++) { object[] attributes = assemblyTypes[i].GetCustomAttributes(typeof(SampleAttribute), true); if (attributes != null && attributes.Length > 0) { SampleAttribute sampleAttribute = (SampleAttribute)attributes[0]; if (sampleAttribute.Category == category) { row = grid1.RowsCount; grid1.Rows.Insert(row); grid1[row, 0] = new SourceGrid.Cells.Cell(sampleAttribute.SampleNumber); grid1[row, 0].View = new SourceGrid.Cells.Views.Cell(); grid1[row, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; //Create a cell with a link grid1[row, 1] = new SourceGrid.Cells.Link(sampleAttribute.Description); grid1[row, 1].Tag = assemblyTypes[i]; grid1[row, 1].Controller.AddController(linkEvents); } } } //Enable sorting of the category range SourceGrid.RangeLoader headerRange = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row, 0, header1.Range.Start.Row, 1)); SourceGrid.RangeLoader rangeToSort = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row + 1, 0, row, 1)); SourceGrid.Cells.Controllers.SortableHeader sortableController = new SourceGrid.Cells.Controllers.SortableHeader(rangeToSort, headerRange); header1.AddController(sortableController); header1.Sort(true); header2.AddController(sortableController); }
public void DoFill(List<Supplier> list) { SupplierGrid.Redim(0, 0); SupplierGrid.FixedRows = 1; SupplierGrid.FixedColumns = 1; SupplierGrid.EnableSort = true; SupplierGrid.Redim(list.Count + 1, 5); SupplierGrid.Rows[0].Height = 25; SupplierGrid[0, 0] = new MyHeader("公司"); SupplierGrid[0, 0].Column.Width = 250; SupplierGrid[0, 0].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); SupplierGrid[0, 1] = new MyHeader("联系人"); SupplierGrid[0, 1].Column.Width = 200; SupplierGrid[0, 1].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); SupplierGrid[0, 2] = new MyHeader("备注"); SupplierGrid[0, 2].Column.Width = 300; SupplierGrid[0, 2].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); SupplierGrid[0, 3] = new MyHeader("地址"); SupplierGrid[0, 3].Column.Width = 200; SupplierGrid[0, 3].AddController(new SourceGrid.Cells.Controllers.SortableHeader()); SupplierGrid[0, 4] = new MyHeader(""); SupplierGrid[0, 4].Column.Width = 100; SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.DoubleClick += new EventHandler(dbClickEvent_Click); int r = 1; foreach (Supplier item in list) { SupplierGrid.Rows[r].Tag = item.Id; SupplierGrid.Rows[r].Height = 35; SupplierGrid[r, 0] = new SourceGrid.Cells.Cell(item.Name); SupplierGrid[r, 0].AddController(clickEvent); SupplierGrid[r, 1] = new SourceGrid.Cells.Cell(item.Contact); SupplierGrid[r, 1].AddController(clickEvent); SupplierGrid[r, 2] = new SourceGrid.Cells.Cell(item.Remark); SupplierGrid[r, 2].AddController(clickEvent); SupplierGrid[r, 3] = new SourceGrid.Cells.Cell(item.Address); SupplierGrid[r, 3].AddController(clickEvent); SupplierGrid[r, 4] = new SourceGrid.Cells.Link("产品列表"); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += new EventHandler(CellButton_Click); SupplierGrid[r, 4].Controller.AddController(buttonClickEvent); r++; } SupplierGrid.ClipboardMode = SourceGrid.ClipboardMode.All; }
private void brAddRow_Click(object sender, System.EventArgs e) { SourceGrid.Cells.Link link = new SourceGrid.Cells.Link("http://www.codeproject.com"); link.AddController(mController_Link); grid1.Rows.Insert(grid1.RowsCount, new SourceGrid.Cells.RowHeader(null), new SourceGrid.Cells.Cell(grid1.RowsCount, mEditor_Id), new SourceGrid.Cells.Cell(mEditor_Name.DefaultValue, mEditor_Name), new SourceGrid.Cells.Cell(mEditor_Address.DefaultValue, mEditor_Address), new SourceGrid.Cells.Cell(mEditor_City.DefaultValue, mEditor_City), new SourceGrid.Cells.Cell(mEditor_BirthDay.DefaultValue, mEditor_BirthDay), new SourceGrid.Cells.Cell(mEditor_Country.DefaultValue, mEditor_Country), new SourceGrid.Cells.Cell(mEditor_Price.DefaultValue, mEditor_Price), new SourceGrid.Cells.CheckBox(null, false), link); grid1.Selection.FocusRow(grid1.RowsCount - 1); }
private void brAddRow_Click(object sender, System.EventArgs e) { int row = grid1.RowsCount; grid1.Rows.Insert(row); grid1[row, 0] = new SourceGrid.Cells.RowHeader(null); grid1[row, 1] = new SourceGrid.Cells.Cell(grid1.RowsCount, mEditor_Id); grid1[row, 2] = new SourceGrid.Cells.Cell(mEditor_Name.DefaultValue, mEditor_Name); grid1[row, 3] = new SourceGrid.Cells.Cell(mEditor_Address.DefaultValue, mEditor_Address); grid1[row, 4] = new SourceGrid.Cells.Cell(mEditor_City.DefaultValue, mEditor_City); grid1[row, 5] = new SourceGrid.Cells.Cell(mEditor_BirthDay.DefaultValue, mEditor_BirthDay); grid1[row, 6] = new SourceGrid.Cells.Cell(mEditor_Country.DefaultValue, mEditor_Country); grid1[row, 7] = new SourceGrid.Cells.Cell(mEditor_Price.DefaultValue, mEditor_Price); grid1[row, 8] = new SourceGrid.Cells.CheckBox(null, false); SourceGrid.Cells.Link link = new SourceGrid.Cells.Link("http://www.codeproject.com"); link.AddController(mController_Link); grid1[row, 9] = link; grid1.Selection.FocusRow(row); }
private void LoadCategorySample(string category, SourceGrid.Cells.Controllers.Button linkEvents, Type[] assemblyTypes, SourceGrid.Cells.Views.IView categoryView, SourceGrid.Cells.Views.IView headerView) { int row; //Create Category Row row = grid1.RowsCount; grid1.Rows.Insert(row); grid1[row, 0] = new SourceGrid.Cells.Cell(category); grid1[row, 0].View = categoryView; grid1[row, 0].ColumnSpan = grid1.ColumnsCount; //Create Headers row = grid1.RowsCount; grid1.Rows.Insert(row); SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader("Sample N°"); header1.View = headerView; header1.AutomaticSortEnabled = false; grid1[row, 0] = header1; SourceGrid.Cells.ColumnHeader header2 = new SourceGrid.Cells.ColumnHeader("Description"); header2.View = headerView; header2.AutomaticSortEnabled = false; grid1[row, 1] = header2; //Create Data Cells for (int i = 0; i < assemblyTypes.Length; i++) { object[] attributes = assemblyTypes[i].GetCustomAttributes(typeof(SampleAttribute), true); if (attributes != null && attributes.Length > 0) { SampleAttribute sampleAttribute = (SampleAttribute)attributes[0]; if (sampleAttribute.Category == category) { row = grid1.RowsCount; grid1.Rows.Insert(row); grid1[row, 0] = new SourceGrid.Cells.Cell( sampleAttribute.SampleNumber ); grid1[row, 0].View = new SourceGrid.Cells.Views.Cell(); grid1[row, 0].View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; //Create a cell with a link grid1[row, 1] = new SourceGrid.Cells.Link( sampleAttribute.Description ); grid1[row, 1].Tag = assemblyTypes[i]; grid1[row, 1].Controller.AddController(linkEvents); } } } //Enable sorting of the category range SourceGrid.RangeLoader headerRange = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row, 0, header1.Range.Start.Row, 1)); SourceGrid.RangeLoader rangeToSort = new SourceGrid.RangeLoader(new SourceGrid.Range(header1.Range.Start.Row+1, 0, row, 1)); SourceGrid.Cells.Controllers.SortableHeader sortableController = new SourceGrid.Cells.Controllers.SortableHeader(rangeToSort, headerRange); header1.AddController(sortableController); header1.Sort(true); header2.AddController(sortableController); }
private void frmSample14_Load(object sender, System.EventArgs e) { grid1.Redim(20, 10); grid1.FixedRows = 2; //1 Header Row grid1[0, 0] = new MyHeader("3 Column Header"); grid1[0, 0].ColumnSpan = 3; grid1[0, 3] = new MyHeader("5 Column Header"); grid1[0, 3].ColumnSpan = 5; grid1[0, 8] = new MyHeader("1 Column Header"); grid1[0, 9] = new MyHeader("1 Column Header"); //2 Header Row grid1[1, 0] = new MyHeader("1"); grid1[1, 1] = new MyHeader("2"); grid1[1, 2] = new MyHeader("3"); grid1[1, 3] = new MyHeader("4"); grid1[1, 4] = new MyHeader("5"); grid1[1, 5] = new MyHeader("6"); grid1[1, 6] = new MyHeader("7"); grid1[1, 7] = new MyHeader("8"); grid1[1, 8] = new MyHeader("9"); grid1[1, 9] = new MyHeader("10"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.Click += new EventHandler(clickEvent_Click); for (int r = 2; r < grid1.RowsCount; r = r + 2) { grid1[r, 0] = new SourceGrid.Cells.Cell(r.ToString(), typeof(string)); grid1[r, 0].ColumnSpan = 2; grid1[r + 1, 0] = new SourceGrid.Cells.Cell(DateTime.Today.AddDays(r), typeof(DateTime)); grid1[r + 1, 0].ColumnSpan = 2; grid1[r, 2] = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false); grid1[r, 2].ColumnSpan = 2; grid1[r, 2].RowSpan = 2; grid1[r, 4] = new SourceGrid.Cells.Link("Link Column/Row Span"); grid1[r, 4].ColumnSpan = 2; grid1[r, 4].RowSpan = 2; grid1[r, 4].AddController(clickEvent); grid1[r, 6] = new SourceGrid.Cells.Button("Button Column/Row Span"); grid1[r, 6].ColumnSpan = 2; grid1[r, 6].RowSpan = 2; grid1[r, 6].AddController(clickEvent); grid1[r, 8] = new SourceGrid.Cells.Cell("Image Column/Row Span"); grid1[r, 8].View = viewImage; grid1[r, 8].Image = Properties.Resources.FACE02.ToBitmap(); grid1[r, 8].ColumnSpan = 2; grid1[r, 8].RowSpan = 2; } grid1.AutoSizeCells(); }
private void frmSampleGrid1_Load(object sender, System.EventArgs e) { string[] l_CountryList = new string[] { "Italy", "France", "Spain", "UK", "Argentina", "Mexico", "Switzerland", "Brazil", "Germany", "Portugal", "Sweden", "Austria" }; grid1.RowsCount = 1; grid1.ColumnsCount = 10; grid1.FixedRows = 1; grid1.FixedColumns = 1; grid1.SelectionMode = SourceGrid.GridSelectionMode.Row; grid1.AutoStretchColumnsToFitWidth = true; grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None; grid1.Columns[0].Width = 25; grid1.Controller.AddController(new KeyDeleteController()); //TODO ////Enable Drag and Drop //grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrag.Cut); //grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrop.Default); #region Create Grid Style, Views and Controllers //Views mView_Price = new SourceGrid.Cells.Views.Cell(); mView_Price.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; mController_Link = new SourceGrid.Cells.Controllers.Button(); mController_Link.Executed += new EventHandler(mController_Link_Click); #endregion #region Create Header Row and Editor SourceGrid.Cells.Header l_00Header = new SourceGrid.Cells.Header(null); grid1[0, 0] = l_00Header; mEditor_Id = SourceGrid.Cells.Editors.Factory.Create(typeof(int)); mEditor_Id.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick; grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("ID (int)"); mEditor_Name = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_Name.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick; grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("NAME (string)"); mEditor_Address = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_Address.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick; grid1[0, 3] = new SourceGrid.Cells.ColumnHeader("ADDRESS (string)"); mEditor_City = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_City.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick; grid1[0, 4] = new SourceGrid.Cells.ColumnHeader("CITY (string)"); mEditor_BirthDay = SourceGrid.Cells.Editors.Factory.Create(typeof(DateTime)); mEditor_BirthDay.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick; grid1[0, 5] = new SourceGrid.Cells.ColumnHeader("BIRTHDATE (DateTime)"); mEditor_Country = new SourceGrid.Cells.Editors.ComboBox(typeof(string), l_CountryList, false); mEditor_Country.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick; grid1[0, 6] = new SourceGrid.Cells.ColumnHeader("COUNTRY (string + combobox)"); mEditor_Price = new SourceGrid.Cells.Editors.TextBoxCurrency(typeof(double)); mEditor_Price.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick; grid1[0, 7] = new SourceGrid.Cells.ColumnHeader("$ PRICE (double)"); grid1[0, 8] = new SourceGrid.Cells.ColumnHeader("Selected"); grid1[0, 9] = new SourceGrid.Cells.ColumnHeader("WebSite"); #endregion //Read Data From xml System.IO.StreamReader reader = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData.xml")); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(reader.ReadToEnd()); reader.Close(); System.Xml.XmlNodeList rows = xmlDoc.SelectNodes("//row"); grid1.RowsCount = rows.Count + 1; int rowsCount = 1; foreach (System.Xml.XmlNode l_Node in rows) { #region Pupulate RowsCount grid1[rowsCount, 0] = new SourceGrid.Cells.RowHeader(null); grid1[rowsCount, 1] = new SourceGrid.Cells.Cell(rowsCount, mEditor_Id); grid1[rowsCount, 2] = new SourceGrid.Cells.Cell(l_Node.Attributes["ContactName"].InnerText, mEditor_Name); grid1[rowsCount, 3] = new SourceGrid.Cells.Cell(l_Node.Attributes["Address"].InnerText, mEditor_Address); grid1[rowsCount, 4] = new SourceGrid.Cells.Cell(l_Node.Attributes["City"].InnerText, mEditor_City); grid1[rowsCount, 5] = new SourceGrid.Cells.Cell(DateTime.Today, mEditor_BirthDay); grid1[rowsCount, 6] = new SourceGrid.Cells.Cell(l_Node.Attributes["Country"].InnerText, mEditor_Country); grid1[rowsCount, 7] = new SourceGrid.Cells.Cell(25.0, mEditor_Price); grid1[rowsCount, 7].View = mView_Price; grid1[rowsCount, 8] = new SourceGrid.Cells.CheckBox(null, false); grid1[rowsCount, 9] = new SourceGrid.Cells.Link(l_Node.Attributes["website"].InnerText); grid1[rowsCount, 9].AddController(mController_Link); #endregion rowsCount++; } grid1.AutoSizeCells(); }
private void frmSample14_Load(object sender, System.EventArgs e) { grid1.Redim(20, 10); grid1.FixedRows = 2; //1 Header Row grid1[0, 0] = new MyHeader("3 Column Header"); grid1[0, 0].ColumnSpan = 3; grid1[0, 3] = new MyHeader("5 Column Header"); grid1[0, 3].ColumnSpan = 5; grid1[0, 8] = new MyHeader("1 Column Header"); grid1[0, 9] = new MyHeader("1 Column Header"); //2 Header Row grid1[1, 0] = new MyHeader("1"); grid1[1, 1] = new MyHeader("2"); grid1[1, 2] = new MyHeader("3"); grid1[1, 3] = new MyHeader("4"); grid1[1, 4] = new MyHeader("5"); grid1[1, 5] = new MyHeader("6"); grid1[1, 6] = new MyHeader("7"); grid1[1, 7] = new MyHeader("8"); grid1[1, 8] = new MyHeader("9"); grid1[1, 9] = new MyHeader("10"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.Click += new EventHandler(clickEvent_Click); for (int r = 2; r < grid1.RowsCount; r=r+2) { grid1[r, 0] = new SourceGrid.Cells.Cell(r.ToString(), typeof(string)); grid1[r, 0].ColumnSpan = 2; grid1[r+1, 0] = new SourceGrid.Cells.Cell(DateTime.Today.AddDays(r), typeof(DateTime)); grid1[r+1, 0].ColumnSpan = 2; grid1[r, 2] = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false); grid1[r, 2].ColumnSpan = 2; grid1[r, 2].RowSpan = 2; grid1[r, 4] = new SourceGrid.Cells.Link("Link Column/Row Span"); grid1[r, 4].ColumnSpan = 2; grid1[r, 4].RowSpan = 2; grid1[r, 4].AddController(clickEvent); grid1[r, 6] = new SourceGrid.Cells.Button("Button Column/Row Span"); grid1[r, 6].ColumnSpan = 2; grid1[r, 6].RowSpan = 2; grid1[r, 6].AddController(clickEvent); grid1[r, 8] = new SourceGrid.Cells.Cell("Image Column/Row Span"); grid1[r, 8].View = viewImage; grid1[r, 8].Image = Properties.Resources.FACE02.ToBitmap(); grid1[r, 8].ColumnSpan = 2; grid1[r, 8].RowSpan = 2; } grid1.AutoSizeCells(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.Redim(62, 3); SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell(); titleModel.BackColor = Color.SteelBlue; titleModel.ForeColor = Color.White; titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell(); captionModel.BackColor = grid.BackColor; int currentRow = 0; #region Base Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //string grid[currentRow, 0] = new SourceGrid.Cells.Cell("String"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string)); currentRow++; //double grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double)); currentRow++; //int grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int)); currentRow++; //DateTime grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); currentRow++; //Boolean grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean)); currentRow++; #endregion #region Complex Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Font grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font)); currentRow++; //Cursor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor)); currentRow++; //Point grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point)); currentRow++; //Rectangle grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle)); currentRow++; //Image grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall); currentRow++; //Enum AnchorStyle grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles)); currentRow++; //Enum grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle)); currentRow++; //String[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array"); grid[currentRow, 0].View = captionModel; string[] strArray = new string[] { "Value 1", "Value 2" }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[])); currentRow++; //Double[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array"); grid[currentRow, 0].View = captionModel; double[] dblArray = new double[] { 1, 0.5, 0.1 }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[])); currentRow++; #endregion #region Special Editors grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Time grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now); grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker(); currentRow++; //Double Chars Validation grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { bool isValid = char.IsNumber(keyArgs.KeyChar) || keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.5); grid[currentRow, 1].Editor = numericEditor; currentRow++; //String Chars (ABC) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Chars Validation(only ABC)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar); bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C'; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AABB"); grid[currentRow, 1].Editor = stringEditor; currentRow++; //String Validating grid[currentRow, 0] = new SourceGrid.Cells.Cell("String validating(min 6 chars)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { string val = ((TextBox)sender).Text; if (val == null || val.Length < 6) { cancelEvent.Cancel = true; } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("test string"); grid[currentRow, 1].Editor = stringEditorValidating; currentRow++; //Int 0-100 or null grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int 0-100 or null"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int)); numericEditor0_100.MinimumValue = 0; numericEditor0_100.MaximumValue = 100; numericEditor0_100.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(7); grid[currentRow, 1].Editor = numericEditor0_100; currentRow++; //Double Custom Conversion grid[currentRow, 0] = new SourceGrid.Cells.Cell("Dbl custom conversion"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double)); dblCustomConversion.ConvertingObjectToValue += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs conv) { if (conv.Value is string) { //Here you can add any custom code double val; if (double.TryParse((string)conv.Value, out val)) { conv.Value = val; conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed; } } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(73.839); grid[currentRow, 1].Editor = dblCustomConversion; currentRow++; //Enum Custom Display grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum Custom Display"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys)); keysCombo.Control.FormattingEnabled = true; keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs) { if (convArgs.Value is Keys) { convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString(); } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Keys.Enter); grid[currentRow, 1].Editor = keysCombo; currentRow++; string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" }; //ComboBox 1 grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); comboStandard.Control.MaxLength = 10; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboStandard); currentRow++; //ComboBox exclusive grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String Exclusive"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive); currentRow++; //ComboBox AutoComplete grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox AutoComplete"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboAutoComplete = new SourceGrid.Cells.Editors.ComboBox(typeof(string), new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" }, true); comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems; comboAutoComplete.Control.AutoCompleteMode = AutoCompleteMode.Append; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete); currentRow++; //ComboBox DropDownList grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DropDownList"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0]); grid[currentRow, 1].Editor = comboNoText; comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList; currentRow++; //ComboBox DateTime Editable grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DateTime"); grid[currentRow, 0].View = captionModel; DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) }; SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime); currentRow++; //ComboBox Custom Display (create a datamodel that has a custom display string) grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Custom Display"); grid[currentRow, 0].View = captionModel; int[] arrInt = new int[] { 0, 1, 2, 3, 4 }; string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" }; SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true); editorComboCustomDisplay.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping(); comboMapping.DisplayStringList = arrStr; comboMapping.ValueList = arrInt; comboMapping.SpecialList = arrStr; comboMapping.SpecialType = typeof(string); comboMapping.BindValidator(editorComboCustomDisplay); grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); grid[currentRow, 1].Editor = editorComboCustomDisplay; SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value); l_CellComboRealValue.View = captionModel; SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue); grid[currentRow, 1].AddController(l_ComboBindProperty); grid[currentRow, 2] = l_CellComboRealValue; currentRow++; //ComboBox with inline View grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Inline View"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); cbInline.EditableMode = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], cbInline); grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default; currentRow++; //Numeric Up Down Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("NumericUpDown"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1); grid[currentRow, 1].Editor = l_NumericUpDownEditor; currentRow++; //Multiline Textbox grid[currentRow, 0] = new SourceGrid.Cells.Cell("Multiline Textbox"); grid[currentRow, 0].View = captionModel; grid[currentRow, 0].ColumnSpan = 1; grid[currentRow, 0].RowSpan = 2; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld"); SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); l_MultilineEditor.Control.Multiline = true; grid[currentRow, 1].Editor = l_MultilineEditor; grid[currentRow, 1].RowSpan = 2; currentRow++; currentRow++; //Boolean (CheckBox) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true); grid[currentRow, 1].FindController <SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow); SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true); l_DisabledCheckBox.Editor.EnableEdit = false; grid[currentRow, 2] = l_DisabledCheckBox; currentRow++; //DateTime with DateTimePicker Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker(); grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDtPicker; currentRow++; //DateTime with DateTimePicker nullable Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker nullable"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker(); editorDtPickerNull.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(null); grid[currentRow, 1].Editor = editorDtPickerNull; currentRow++; //File editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("File editor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog()); currentRow++; // Richtext box grid[currentRow, 0] = new SourceGrid.Cells.Cell("RichTextBox editor"); grid[currentRow, 0].View = captionModel; string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" + "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " + "Test\\b0.\\par\r\n}\r\n"; var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf)); grid[currentRow, 1] = richTextBox; currentRow++; #endregion #region Special Cells grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Cells"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Button grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Button"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Button("CellButton"); grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap(); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += new EventHandler(CellButton_Click); grid[currentRow, 1].Controller.AddController(buttonClickEvent); currentRow++; //Cell Link grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Link"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Link("CellLink"); SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button(); linkClickEvent.Executed += new EventHandler(CellLink_Click); grid[currentRow, 1].Controller.AddController(linkClickEvent); currentRow++; //Custom draw cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom draw cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("CustomView"); grid[currentRow, 1].View = new RoundView(); currentRow++; //Control Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Control Cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("control cell"); ProgressBar progressBar = new ProgressBar(); progressBar.Value = 50; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1))); currentRow++; //Custom Border Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell(); viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1), new DevAge.Drawing.BorderLine(Color.Blue, 1), new DevAge.Drawing.BorderLine(Color.Violet, 1), new DevAge.Drawing.BorderLine(Color.Green, 1)); grid[currentRow, 1] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 1].View = viewCustomBorder; currentRow++; #endregion #region Custom Formatting grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Formatting"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Format grid[currentRow, 0] = new SourceGrid.Cells.Cell("Default Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Percent Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Percent Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double)); l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double)); grid[currentRow, 1].Editor = l_PercentEditor; currentRow++; //Currency Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Currency Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M); SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal)); l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal)); grid[currentRow, 1].Editor = l_CurrencyEditor; currentRow++; //Format (#.00) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format #.00"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "#.00"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("0000.0000") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format 0000.0000"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "0000.0000"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("Scientific (exponential)") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format Scientific"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006); SourceGrid.Cells.Editors.TextBoxNumeric editorExponential = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e"); exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent; editorExponential.TypeConverter = exponentialConverter; grid[currentRow, 1].Editor = editorExponential; currentRow++; //DateTime 2 (using custom formatting) string dtFormat2 = "yyyy MM dd"; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")"); grid[currentRow, 0].View = captionModel; string[] dtParseFormats = new string[] { dtFormat2 }; System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles); SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime)); editorDt2.TypeConverter = dtConverter; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDt2; currentRow++; //Text Ellipses grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Ellipses"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string)); SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell(); ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word; grid[currentRow, 1].View = ellipsesView; currentRow++; #endregion #region Image And Text Properties grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image And Text Properties"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Image SourceGrid.Cells.Cell cellImage1 = new SourceGrid.Cells.Cell("Single Image"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(captionModel); cellImage1.View = viewImage; grid[currentRow, 2] = cellImage1; cellImage1.RowSpan = 4; cellImage1.Image = Properties.Resources.FACE02.ToBitmap(); grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Stretch Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("DrawMode"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage)); currentRow++; // Cell VisualModelMultiImages grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images"); SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages(); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap())); modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false); modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false); modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false); modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false); modelMultiImages.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; grid[currentRow, 1].View = modelMultiImages; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // Cell Rotated Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rotated by angle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Rotated Text", typeof(string)); SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell(); rotateView.ElementText = new RotatedText(45); grid[currentRow, 1].View = rotateView; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // GDI+ Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("GDI+ Text"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string)); GDITextView gdiTextView = new GDITextView(); gdiTextView.FormatFlags = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap; grid[currentRow, 1].View = gdiTextView; currentRow++; #endregion grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.MinimumWidth = 50; grid.AutoSizeCells(); grid.AutoStretchColumnsToFitWidth = true; grid.Columns.StretchToFit(); }
private void CellLink_Click(object sender, EventArgs e) { SourceGrid.CellContext context = (SourceGrid.CellContext)sender; SourceGrid.Cells.Link btnCell = (SourceGrid.Cells.Link)context.Cell; btnCell.Value = DateTime.Now.TimeOfDay.ToString(); }
private void DoFull() { grid1.Redim(20, 12); grid1.FixedRows = 2; //1 Header Row grid1[0, 0] = new MyHeader("3 Column Header"); grid1[0, 0].ColumnSpan = 3; grid1[0, 3] = new MyHeader("5 Column Header"); grid1[0, 3].ColumnSpan = 5; grid1[0, 8] = new MyHeader("1 Column Header"); grid1[0, 9] = new MyHeader("1 Column Header"); //2 Header Row grid1[1, 0] = new MyHeader("1"); grid1[1, 1] = new MyHeader("2"); grid1[1, 2] = new MyHeader("3"); grid1[1, 3] = new MyHeader("4"); grid1[1, 4] = new MyHeader("5"); grid1[1, 5] = new MyHeader("6"); grid1[1, 6] = new MyHeader("7"); grid1[1, 7] = new MyHeader("8"); grid1[1, 8] = new MyHeader("9"); grid1[1, 9] = new MyHeader("10"); grid1[1, 10] = new MyHeader("11"); grid1[1, 11] = new MyHeader("12"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.Click += new EventHandler(clickEvent_Click); for (int r = 2; r < grid1.RowsCount; r = r + 2) { grid1[r, 0] = new SourceGrid.Cells.Cell(r.ToString(), typeof(string)); grid1[r, 0].ColumnSpan = 2; grid1[r + 1, 0] = new SourceGrid.Cells.Cell(); grid1[r + 1, 0].ColumnSpan = 2; grid1[r, 2] = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false); grid1[r, 2].ColumnSpan = 2; grid1[r, 2].RowSpan = 2; grid1[r, 4] = new SourceGrid.Cells.Link("Link Column/Row Span"); grid1[r, 4].ColumnSpan = 2; grid1[r, 4].RowSpan = 2; grid1[r, 4].AddController(clickEvent); grid1[r, 6] = new SourceGrid.Cells.Button("Button Column/Row Span"); grid1[r, 6].ColumnSpan = 2; grid1[r, 6].RowSpan = 2; grid1[r, 6].AddController(clickEvent); grid1[r, 8] = new SourceGrid.Cells.Cell("Image Column/Row Span"); grid1[r, 8].View = viewImage; grid1[r, 8].Image = Properties.Resources.FACE02.ToBitmap(); grid1[r, 8].ColumnSpan = 2; grid1[r, 8].RowSpan = 2; grid1[r, 10] = new SourceGrid.Cells.Cell("Text Span", typeof(string)); grid1[r, 10].ColumnSpan = 2; grid1[r, 10].RowSpan = 2; } grid1.ClipboardMode = SourceGrid.ClipboardMode.All; grid1.AutoSizeCells(); }
private void brAddRow_Click(object sender, System.EventArgs e) { int row = grid1.RowsCount; grid1.Rows.Insert(row); grid1[row, 0] = new SourceGrid.Cells.RowHeader(null); grid1[row, 1] = new SourceGrid.Cells.Cell(grid1.RowsCount, mEditor_Id); grid1[row, 2] = new SourceGrid.Cells.Cell(mEditor_Name.DefaultValue, mEditor_Name); grid1[row, 3] = new SourceGrid.Cells.Cell(mEditor_Address.DefaultValue,mEditor_Address); grid1[row, 4] = new SourceGrid.Cells.Cell(mEditor_City.DefaultValue,mEditor_City); grid1[row, 5] = new SourceGrid.Cells.Cell(mEditor_BirthDay.DefaultValue, mEditor_BirthDay); grid1[row, 6] = new SourceGrid.Cells.Cell(mEditor_Country.DefaultValue, mEditor_Country); grid1[row, 7] = new SourceGrid.Cells.Cell(mEditor_Price.DefaultValue, mEditor_Price); grid1[row, 8] = new SourceGrid.Cells.CheckBox(null, false); SourceGrid.Cells.Link link = new SourceGrid.Cells.Link("http://www.codeproject.com"); link.AddController(mController_Link); grid1[row, 9] = link; grid1.Selection.FocusRow(row); }
private void frmSampleGrid1_Load(object sender, System.EventArgs e) { string[] l_CountryList = new string[]{"Italy","France","Spain","UK","Argentina","Mexico", "Switzerland", "Brazil", "Germany","Portugal","Sweden","Austria"}; grid1.RowsCount = 1; grid1.ColumnsCount = 10; grid1.FixedRows = 1; grid1.FixedColumns = 1; grid1.SelectionMode = SourceGrid.GridSelectionMode.Row; grid1.AutoStretchColumnsToFitWidth = true; grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.None; grid1.Columns[0].Width = 25; grid1.Controller.AddController(new KeyDeleteController()); //TODO ////Enable Drag and Drop //grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrag.Cut); //grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrop.Default); #region Create Grid Style, Views and Controllers //Views mView_Price = new SourceGrid.Cells.Views.Cell(); mView_Price.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; mController_Link = new SourceGrid.Cells.Controllers.Button(); mController_Link.Executed += new EventHandler(mController_Link_Click); #endregion #region Create Header Row and Editor SourceGrid.Cells.Header l_00Header = new SourceGrid.Cells.Header(null); grid1[0,0] = l_00Header; mEditor_Id = SourceGrid.Cells.Editors.Factory.Create(typeof(int)); mEditor_Id.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,1] = new SourceGrid.Cells.ColumnHeader("ID (int)"); mEditor_Name = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_Name.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,2] = new SourceGrid.Cells.ColumnHeader("NAME (string)"); mEditor_Address = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_Address.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,3] = new SourceGrid.Cells.ColumnHeader("ADDRESS (string)"); mEditor_City = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); mEditor_City.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,4] = new SourceGrid.Cells.ColumnHeader("CITY (string)"); mEditor_BirthDay = SourceGrid.Cells.Editors.Factory.Create(typeof(DateTime)); mEditor_BirthDay.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,5] = new SourceGrid.Cells.ColumnHeader("BIRTHDATE (DateTime)"); mEditor_Country = new SourceGrid.Cells.Editors.ComboBox(typeof(string),l_CountryList,false); mEditor_Country.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,6] = new SourceGrid.Cells.ColumnHeader("COUNTRY (string + combobox)"); mEditor_Price = new SourceGrid.Cells.Editors.TextBoxCurrency(typeof(double)); mEditor_Price.EditableMode = SourceGrid.EditableMode.Focus|SourceGrid.EditableMode.AnyKey|SourceGrid.EditableMode.SingleClick; grid1[0,7] = new SourceGrid.Cells.ColumnHeader("$ PRICE (double)"); grid1[0,8] = new SourceGrid.Cells.ColumnHeader("Selected"); grid1[0,9] = new SourceGrid.Cells.ColumnHeader("WebSite"); #endregion //Read Data From xml System.IO.StreamReader reader = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData.xml")); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(reader.ReadToEnd()); reader.Close(); System.Xml.XmlNodeList rows = xmlDoc.SelectNodes("//row"); grid1.RowsCount = rows.Count+1; int rowsCount = 1; foreach(System.Xml.XmlNode l_Node in rows) { #region Pupulate RowsCount grid1[rowsCount,0] = new SourceGrid.Cells.RowHeader(null); grid1[rowsCount,1] = new SourceGrid.Cells.Cell(rowsCount, mEditor_Id); grid1[rowsCount,2] = new SourceGrid.Cells.Cell(l_Node.Attributes["ContactName"].InnerText, mEditor_Name); grid1[rowsCount,3] = new SourceGrid.Cells.Cell(l_Node.Attributes["Address"].InnerText, mEditor_Address); grid1[rowsCount,4] = new SourceGrid.Cells.Cell(l_Node.Attributes["City"].InnerText, mEditor_City); grid1[rowsCount,5] = new SourceGrid.Cells.Cell(DateTime.Today, mEditor_BirthDay); grid1[rowsCount,6] = new SourceGrid.Cells.Cell(l_Node.Attributes["Country"].InnerText, mEditor_Country); grid1[rowsCount,7] = new SourceGrid.Cells.Cell(25.0, mEditor_Price); grid1[rowsCount, 7].View = mView_Price; grid1[rowsCount,8] = new SourceGrid.Cells.CheckBox(null, false); grid1[rowsCount,9] = new SourceGrid.Cells.Link(l_Node.Attributes["website"].InnerText); grid1[rowsCount,9].AddController(mController_Link); #endregion rowsCount++; } grid1.AutoSizeCells(); }
private static void CreateColumns(SourceGrid.DataGridColumns columns, DataTable sourceTable) { SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(decimal)); numericEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(decimal), "N"); numericEditor.AllowNull = true; SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); //Borders DevAge.Drawing.RectangleBorder border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.Border(Color.ForestGreen), new DevAge.Drawing.Border(Color.ForestGreen)); //Standard Views SourceGrid.Cells.Views.Link viewLink = new SourceGrid.Cells.Views.Link(); viewLink.BackColor = Color.DarkSeaGreen; viewLink.Border = border; viewLink.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; viewLink.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell viewString = new SourceGrid.Cells.Views.Cell(); viewString.BackColor = Color.DarkSeaGreen; viewString.Border = border; viewString.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft; SourceGrid.Cells.Views.Cell viewNumeric = new SourceGrid.Cells.Views.Cell(); viewNumeric.BackColor = Color.DarkSeaGreen; viewNumeric.Border = border; viewNumeric.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); viewImage.BackColor = Color.DarkSeaGreen; viewImage.Border = border; viewImage.ImageStretch = false; viewImage.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; Color alternateColor = Color.LightGray; DataColumn dataColumn; DataGridColumnAlternate gridColumn; SourceGrid.Cells.ICellVirtual dataCell; //Create columns dataCell = new SourceGrid.Cells.Link(""); dataCell.AddController(new LinkClickDelete()); dataCell.View = viewLink; ((SourceGrid.Cells.Link)dataCell).Image = Properties.Resources.trash.ToBitmap(); gridColumn = new DataGridColumnAlternate(columns.Grid, null, "Delete", dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); //Add an image to the header dataColumn = sourceTable.Columns["Flag"]; dataCell = new SourceGrid.Cells.DataGrid.Image(dataColumn); dataCell.View = viewImage; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Country"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Uniform"]; dataCell = new SourceGrid.Cells.DataGrid.Image(dataColumn); dataCell.View = viewImage; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Capital"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Population"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewNumeric; dataCell.Editor = numericEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Surface"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewNumeric; dataCell.Editor = numericEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Languages"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Currency"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Major Cities"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["National Holiday"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Lowest point"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Highest point"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.View = viewString; dataCell.Editor = stringEditor; gridColumn = new DataGridColumnAlternate(columns.Grid, dataColumn, dataColumn.Caption, dataCell, alternateColor); columns.Insert(columns.Count, gridColumn); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.Redim(62, 3); SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell(); titleModel.BackColor = Color.SteelBlue; titleModel.ForeColor = Color.White; titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell(); captionModel.BackColor = grid.BackColor; int currentRow = 0; #region Base Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //string grid[currentRow, 0] = new SourceGrid.Cells.Cell("String"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string)); currentRow++; //double grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double)); currentRow++; //int grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int)); currentRow++; //DateTime grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); currentRow++; //Boolean grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean)); currentRow++; #endregion #region Complex Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Font grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font)); currentRow++; //Cursor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor)); currentRow++; //Point grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point)); currentRow++; //Rectangle grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle)); currentRow++; //Image grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall); currentRow++; //Enum AnchorStyle grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles)); currentRow++; //Enum grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle)); currentRow++; //String[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array"); grid[currentRow, 0].View = captionModel; string[] strArray = new string[] { "Value 1", "Value 2" }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[])); currentRow++; //Double[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array"); grid[currentRow, 0].View = captionModel; double[] dblArray = new double[] { 1, 0.5, 0.1 }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[])); currentRow++; #endregion #region Special Editors grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Time grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now); grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker(); currentRow++; //Double Chars Validation grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { bool isValid = char.IsNumber(keyArgs.KeyChar) || keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.5); grid[currentRow, 1].Editor = numericEditor; currentRow++; //String Chars (ABC) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Chars Validation(only ABC)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar); bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C'; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AABB"); grid[currentRow, 1].Editor = stringEditor; currentRow++; //String Validating grid[currentRow, 0] = new SourceGrid.Cells.Cell("String validating(min 6 chars)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { string val = ((TextBox)sender).Text; if (val == null || val.Length < 6) cancelEvent.Cancel = true; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("test string"); grid[currentRow, 1].Editor = stringEditorValidating; currentRow++; //Int 0-100 or null grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int 0-100 or null"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int)); numericEditor0_100.MinimumValue = 0; numericEditor0_100.MaximumValue = 100; numericEditor0_100.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(7); grid[currentRow, 1].Editor = numericEditor0_100; currentRow++; //Double Custom Conversion grid[currentRow, 0] = new SourceGrid.Cells.Cell("Dbl custom conversion"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double)); dblCustomConversion.ConvertingObjectToValue += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs conv) { if (conv.Value is string) { //Here you can add any custom code double val; if (double.TryParse((string)conv.Value, out val)) { conv.Value = val; conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed; } } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(73.839); grid[currentRow, 1].Editor = dblCustomConversion; currentRow++; //Enum Custom Display grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum Custom Display"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys)); keysCombo.Control.FormattingEnabled = true; keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs) { if (convArgs.Value is Keys) convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString(); }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Keys.Enter); grid[currentRow, 1].Editor = keysCombo; currentRow++; string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" }; //ComboBox 1 grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); comboStandard.Control.MaxLength = 10; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboStandard); currentRow++; //ComboBox exclusive grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String Exclusive"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive); currentRow++; //ComboBox AutoComplete grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox AutoComplete"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboAutoComplete = new SourceGrid.Cells.Editors.ComboBox(typeof(string), new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" }, true); comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems; comboAutoComplete.Control.AutoCompleteMode = AutoCompleteMode.Append; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete); currentRow++; //ComboBox DropDownList grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DropDownList"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0]); grid[currentRow, 1].Editor = comboNoText; comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList; currentRow++; //ComboBox DateTime Editable grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DateTime"); grid[currentRow, 0].View = captionModel; DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) }; SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime); currentRow++; //ComboBox Custom Display (create a datamodel that has a custom display string) grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Custom Display"); grid[currentRow, 0].View = captionModel; int[] arrInt = new int[] { 0, 1, 2, 3, 4 }; string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" }; SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true); editorComboCustomDisplay.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping(); comboMapping.DisplayStringList = arrStr; comboMapping.ValueList = arrInt; comboMapping.SpecialList = arrStr; comboMapping.SpecialType = typeof(string); comboMapping.BindValidator(editorComboCustomDisplay); grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); grid[currentRow, 1].Editor = editorComboCustomDisplay; SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value); l_CellComboRealValue.View = captionModel; SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue); grid[currentRow, 1].AddController(l_ComboBindProperty); grid[currentRow, 2] = l_CellComboRealValue; currentRow++; //ComboBox with inline View grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Inline View"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); cbInline.EditableMode = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], cbInline); grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default; currentRow++; //Numeric Up Down Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("NumericUpDown"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1); grid[currentRow, 1].Editor = l_NumericUpDownEditor; currentRow++; //Multiline Textbox grid[currentRow, 0] = new SourceGrid.Cells.Cell("Multiline Textbox"); grid[currentRow, 0].View = captionModel; grid[currentRow, 0].ColumnSpan = 1; grid[currentRow, 0].RowSpan = 2; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld"); SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); l_MultilineEditor.Control.Multiline = true; grid[currentRow, 1].Editor = l_MultilineEditor; grid[currentRow, 1].RowSpan = 2; currentRow++; currentRow++; //Boolean (CheckBox) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true); grid[currentRow, 1].FindController<SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow); SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true); l_DisabledCheckBox.Editor.EnableEdit = false; grid[currentRow, 2] = l_DisabledCheckBox; currentRow++; //DateTime with DateTimePicker Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker(); grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDtPicker; currentRow++; //DateTime with DateTimePicker nullable Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker nullable"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker(); editorDtPickerNull.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(null); grid[currentRow, 1].Editor = editorDtPickerNull; currentRow++; //File editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("File editor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog()); currentRow++; // Richtext box grid[currentRow, 0] = new SourceGrid.Cells.Cell("RichTextBox editor"); grid[currentRow, 0].View = captionModel; string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" + "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " + "Test\\b0.\\par\r\n}\r\n"; var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf)); grid[currentRow, 1] = richTextBox; currentRow++; #endregion #region Special Cells grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Cells"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Button grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Button"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Button("CellButton"); grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap(); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += new EventHandler(CellButton_Click); grid[currentRow, 1].Controller.AddController(buttonClickEvent); currentRow++; //Cell Link grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Link"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Link("CellLink"); SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button(); linkClickEvent.Executed += new EventHandler(CellLink_Click); grid[currentRow, 1].Controller.AddController(linkClickEvent); currentRow++; //Custom draw cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom draw cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("CustomView"); grid[currentRow, 1].View = new RoundView(); currentRow++; //Control Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Control Cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("control cell"); ProgressBar progressBar = new ProgressBar(); progressBar.Value = 50; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1))); currentRow++; //Custom Border Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell(); viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1), new DevAge.Drawing.BorderLine(Color.Blue, 1), new DevAge.Drawing.BorderLine(Color.Violet, 1), new DevAge.Drawing.BorderLine(Color.Green, 1)); grid[currentRow, 1] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 1].View = viewCustomBorder; currentRow++; #endregion #region Custom Formatting grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Formatting"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Format grid[currentRow, 0] = new SourceGrid.Cells.Cell("Default Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Percent Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Percent Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double)); l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double)); grid[currentRow, 1].Editor = l_PercentEditor; currentRow++; //Currency Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Currency Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M); SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal)); l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal)); grid[currentRow, 1].Editor = l_CurrencyEditor; currentRow++; //Format (#.00) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format #.00"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "#.00"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("0000.0000") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format 0000.0000"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "0000.0000"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("Scientific (exponential)") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format Scientific"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006); SourceGrid.Cells.Editors.TextBoxNumeric editorExponential = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e"); exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent; editorExponential.TypeConverter = exponentialConverter; grid[currentRow, 1].Editor = editorExponential; currentRow++; //DateTime 2 (using custom formatting) string dtFormat2 = "yyyy MM dd"; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")"); grid[currentRow, 0].View = captionModel; string[] dtParseFormats = new string[] { dtFormat2 }; System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles); SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime)); editorDt2.TypeConverter = dtConverter; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDt2; currentRow++; //Text Ellipses grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Ellipses"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string)); SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell(); ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word; grid[currentRow, 1].View = ellipsesView; currentRow++; #endregion #region Image And Text Properties grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image And Text Properties"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Image SourceGrid.Cells.Cell cellImage1 = new SourceGrid.Cells.Cell("Single Image"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(captionModel); cellImage1.View = viewImage; grid[currentRow, 2] = cellImage1; cellImage1.RowSpan = 4; cellImage1.Image = Properties.Resources.FACE02.ToBitmap(); grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Stretch Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("DrawMode"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage)); currentRow++; // Cell VisualModelMultiImages grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images"); SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages(); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap())); modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false); modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false); modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false); modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false); modelMultiImages.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; grid[currentRow, 1].View = modelMultiImages; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // Cell Rotated Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rotated by angle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Rotated Text", typeof(string)); SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell(); rotateView.ElementText = new RotatedText(45); grid[currentRow, 1].View = rotateView; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // GDI+ Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("GDI+ Text"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string)); GDITextView gdiTextView = new GDITextView(); gdiTextView.FormatFlags = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap; grid[currentRow, 1].View = gdiTextView; currentRow++; #endregion grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.MinimumWidth = 50; grid.AutoSizeCells(); grid.AutoStretchColumnsToFitWidth = true; grid.Columns.StretchToFit(); }
private void DoFull() { grid1.Redim(20, 12); grid1.FixedRows = 2; //1 Header Row grid1[0, 0] = new MyHeader("3 Column Header"); grid1[0, 0].ColumnSpan = 3; grid1[0, 3] = new MyHeader("5 Column Header"); grid1[0, 3].ColumnSpan = 5; grid1[0, 8] = new MyHeader("1 Column Header"); grid1[0, 9] = new MyHeader("1 Column Header"); //2 Header Row grid1[1, 0] = new MyHeader("1"); grid1[1, 1] = new MyHeader("2"); grid1[1, 2] = new MyHeader("3"); grid1[1, 3] = new MyHeader("4"); grid1[1, 4] = new MyHeader("5"); grid1[1, 5] = new MyHeader("6"); grid1[1, 6] = new MyHeader("7"); grid1[1, 7] = new MyHeader("8"); grid1[1, 8] = new MyHeader("9"); grid1[1, 9] = new MyHeader("10"); grid1[1, 10] = new MyHeader("11"); grid1[1, 11] = new MyHeader("12"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents(); clickEvent.Click += new EventHandler(clickEvent_Click); for (int r = 2; r < grid1.RowsCount; r=r+2) { grid1[r, 0] = new SourceGrid.Cells.Cell(r.ToString(), typeof(string)); grid1[r, 0].ColumnSpan = 2; grid1[r+1, 0] = new SourceGrid.Cells.Cell(); grid1[r+1, 0].ColumnSpan = 2; grid1[r, 2] = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false); grid1[r, 2].ColumnSpan = 2; grid1[r, 2].RowSpan = 2; grid1[r, 4] = new SourceGrid.Cells.Link("Link Column/Row Span"); grid1[r, 4].ColumnSpan = 2; grid1[r, 4].RowSpan = 2; grid1[r, 4].AddController(clickEvent); grid1[r, 6] = new SourceGrid.Cells.Button("Button Column/Row Span"); grid1[r, 6].ColumnSpan = 2; grid1[r, 6].RowSpan = 2; grid1[r, 6].AddController(clickEvent); grid1[r, 8] = new SourceGrid.Cells.Cell("Image Column/Row Span"); grid1[r, 8].View = viewImage; grid1[r, 8].Image = Properties.Resources.FACE02.ToBitmap(); grid1[r, 8].ColumnSpan = 2; grid1[r, 8].RowSpan = 2; grid1[r, 10] = new SourceGrid.Cells.Cell("Text Span", typeof(string)); grid1[r, 10].ColumnSpan = 2; grid1[r, 10].RowSpan = 2; } grid1.ClipboardMode = SourceGrid.ClipboardMode.All; grid1.AutoSizeCells(); }