//Override the Assign method public override void Assign(RepositoryItem item) { BeginUpdate(); try { base.Assign(item); RepositoryItemCustomEdit source = item as RepositoryItemCustomEdit; if (source == null) { return; } } finally { EndUpdate(); } }
private void Form1_Load(object sender, EventArgs e) { DataHelper helper = new DataHelper(imageList1); DataSet dataSet1 = new DataSet(); dataSet1.Tables.Add(helper.CreateTable()); dataSet1.Tables.Add(helper.CreateEmptyTable()); DataColumn keyColumn = dataSet1.Tables[0].Columns["CustomerID"]; DataColumn foreignKeyColumn = dataSet1.Tables[1].Columns["CustomerID"]; dataSet1.Relations.Add("CustomerInfo_CustomerInfo1", keyColumn, foreignKeyColumn); gridControl1.DataSource = dataSet1.Tables[0]; RepositoryItemCustomEdit edit = new RepositoryItemCustomEdit(); gridControl1.RepositoryItems.Add(edit); colFirstName.ColumnEdit = edit; }
protected override void DrawContent(ControlGraphicsInfoArgs info) { base.DrawContent(info); BaseEditViewInfo viewInfo = info.ViewInfo as BaseEditViewInfo; RepositoryItemCustomEdit item = viewInfo.Item as RepositoryItemCustomEdit; string[] values = item.ParseValues(viewInfo.EditValue); string[] captions = item.GetRowCaptions(); Color rowHeaderColor = GetRowHeaderColor(); Color gridLineColor = GetGridLineColor(); Color gridBorderColor = GetGridBorderColor(); for (int i = 0; i < 5; i++) { Rectangle rowHeaderRect = new Rectangle(info.Bounds.X + 1, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * i + i + 1, RepositoryItemCustomEdit.RowHeaderWidth, RepositoryItemCustomEdit.RowHeight); Rectangle recordRect = new Rectangle(rowHeaderRect.Right + 2, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * i + i, RepositoryItemCustomEdit.RecordWidth, RepositoryItemCustomEdit.RowHeight); info.Graphics.DrawLine(new Pen(gridLineColor), info.Bounds.X, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * i + i, recordRect.Right + 3, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * i + i); if (values.Length > i) { info.Graphics.DrawString(values[i], info.ViewInfo.PaintAppearance.Font, info.ViewInfo.PaintAppearance.GetForeBrush(info.Cache), recordRect.Location); } info.Graphics.FillRectangle(new SolidBrush(rowHeaderColor), rowHeaderRect); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Far; info.Graphics.DrawString(captions[i], info.ViewInfo.PaintAppearance.Font, info.ViewInfo.PaintAppearance.GetForeBrush(info.Cache), rowHeaderRect, format); } info.Graphics.DrawLine(new Pen(gridLineColor), info.Bounds.X, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * 5 + 5, info.Bounds.X + RepositoryItemCustomEdit.RowHeaderWidth + RepositoryItemCustomEdit.RecordWidth + 3, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * 5 + 5); info.Graphics.DrawLine(new Pen(gridLineColor), info.Bounds.X, info.Bounds.Y, info.Bounds.X, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * 5 + 5); info.Graphics.DrawLine(new Pen(gridLineColor), info.Bounds.X + RepositoryItemCustomEdit.RowHeaderWidth + RepositoryItemCustomEdit.RecordWidth + 5, info.Bounds.Y, info.Bounds.X + RepositoryItemCustomEdit.RowHeaderWidth + RepositoryItemCustomEdit.RecordWidth + 5, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * 5 + 5); info.Graphics.DrawLine(new Pen(gridLineColor), info.Bounds.X + RepositoryItemCustomEdit.RowHeaderWidth + 1, info.Bounds.Y, info.Bounds.X + RepositoryItemCustomEdit.RowHeaderWidth + 1, info.Bounds.Y + RepositoryItemCustomEdit.RowHeight * 5 + 5); }
//The static constructor which calls the registration method static CustomEdit() { RepositoryItemCustomEdit.RegisterCustomEdit(); }