GrapeCity.Win.MultiRow Namespace > GcMultiRow Class : EditingControlShowing Event |
<SRDescriptionAttribute("Occurs when a control for editing a cell is showing.")> <SRCategoryAttribute("Action")> Public Event EditingControlShowing As EventHandler(Of EditingControlShowingEventArgs)
Dim instance As GcMultiRow Dim handler As EventHandler(Of EditingControlShowingEventArgs) AddHandler instance.EditingControlShowing, handler
[SRDescription("Occurs when a control for editing a cell is showing.")] [SRCategory("Action")] public event EventHandler<EditingControlShowingEventArgs> EditingControlShowing
The event handler receives an argument of type EditingControlShowingEventArgs containing data related to this event. The following EditingControlShowingEventArgs properties provide information specific to this event.
Property | Description |
---|---|
CellStyle | Gets or sets the cell style of the edited cell. |
Control | Gets the control shown to the user for editing the selected cell's value. |
You can handle this event to perform custom initialization of the editing control when a cell enters edit mode. To customize the display characteristics of the control, set the properties of the object returned by the EditingControlShowingEventArgs.CellStyle property. To perform other initializations, cast the EditingControlShowingEventArgs.Control property value to the specific control type and access the members directly. For example, you can handle the EditingControlShowing event so you can attach event handlers to the editing control events.
Note: |
---|
The GcMultiRow control hosts one editing control at a time, and reuses the editing control whenever the cell type does not change between edits. When attaching event handlers to the editing control, you must take precautions to avoid attaching the same handler multiple times. To avoid this problem, remove the handler from the event before you attach the handler to the event. This will prevent duplication if the handler is already attached to the event and has no other effects. |
class EditingControlShowingDemo : Form { GcMultiRow gcMultiRow = new GcMultiRow(); public EditingControlShowingDemo() { gcMultiRow.Dock = DockStyle.Fill; gcMultiRow.Template = Template.Default; gcMultiRow.RowCount = 5; gcMultiRow.EditingControlShowing += new EventHandler<EditingControlShowingEventArgs>(gcMultiRow_EditingControlShowing); this.Text = "EditingControlShowing Demo"; this.Controls.Add(gcMultiRow); } void gcMultiRow_EditingControlShowing(object sender, EditingControlShowingEventArgs e) { // Change editing control's backcolor. e.CellStyle.BackColor = Color.Red; TextBox textBox = e.Control as TextBox; if (textBox != null) { // Add TextChange event handler. textBox.TextChanged -= new EventHandler(textBox_TextChanged); textBox.TextChanged += new EventHandler(textBox_TextChanged); } }
Class EditingControlShowingDemo Inherits Form Friend WithEvents gcMultiRow As New GcMultiRow() Public Sub New() gcMultiRow.Dock = DockStyle.Fill gcMultiRow.Template = Template.Default gcMultiRow.RowCount = 5 Me.Text = "EditingControlShowingDemo" Me.Controls.Add(gcMultiRow) End Sub Private Sub gcMultiRow_EditingControlShowing(ByVal sender As Object, ByVal e As EditingControlShowingEventArgs) Handles gcMultiRow.EditingControlShowing ' Change editing control's backcolor. e.CellStyle.BackColor = Color.Red Dim textBox As TextBox = TryCast(e.Control, TextBox) If Not textBox Is Nothing Then ' Add TextChange event handler. RemoveHandler textBox.TextChanged, AddressOf textBox_TextChanged AddHandler textBox.TextChanged, AddressOf textBox_TextChanged End If End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2