R
Richard Lewis Haggard
I've created a RichTextBox DataGridView cell but the first character entered
when the cell is in display mode is lost when the cell makes the transition
to edit mode. What is the sequence of events that happens behind the scenes
when:
a) RichTextBox cell is displaying data and has focus.
b) User enters a keyboard character.
c) Cell transitions to edit mode.
When the edit process starts, the editor control collects the data that is
present in the cell and sets its own value to it. Initially, of course, this
is an empty string. Any subsequent keystrokes are properly handled by the
RichTextBox control but the initial keystroke that triggered the display of
this control is lost.
I did do one odd thing - I got tired of having that stupid page show up that
said design mode was unavailable for the RichTextBoxEditingControl so I
encapsulated the RichTextBox itself into a User Control. The
RichTextBoxEditingControl is derived from the RichTextBox encapsulating User
Control and this makes Visual Studio '05 happy.
public partial class RichTextBoxControl : UserControl
{
// Accessor to allow operations on the contained RichTextBox
// The child RichTextBox control was added to the UserControl form as
richTextBox.
public RichTextBox RichTextBox { get { return richTextBox; } }
public RichTextBoxControl()
{
InitalizeComponent();
}
}
public class RichTextBoxEditingControl : RichTextBoxControl,
IDataGridViewEditingControl
{
// Bunches of code to implement the IDataGridViewEditingControl
interface.
// Influenced by the MSDN DateTIme Calendar sample.
// ...
}
Any suggestions on where the lost character is going to and, more
importantly, how I can get it into the RichTextBox?
when the cell is in display mode is lost when the cell makes the transition
to edit mode. What is the sequence of events that happens behind the scenes
when:
a) RichTextBox cell is displaying data and has focus.
b) User enters a keyboard character.
c) Cell transitions to edit mode.
When the edit process starts, the editor control collects the data that is
present in the cell and sets its own value to it. Initially, of course, this
is an empty string. Any subsequent keystrokes are properly handled by the
RichTextBox control but the initial keystroke that triggered the display of
this control is lost.
I did do one odd thing - I got tired of having that stupid page show up that
said design mode was unavailable for the RichTextBoxEditingControl so I
encapsulated the RichTextBox itself into a User Control. The
RichTextBoxEditingControl is derived from the RichTextBox encapsulating User
Control and this makes Visual Studio '05 happy.
public partial class RichTextBoxControl : UserControl
{
// Accessor to allow operations on the contained RichTextBox
// The child RichTextBox control was added to the UserControl form as
richTextBox.
public RichTextBox RichTextBox { get { return richTextBox; } }
public RichTextBoxControl()
{
InitalizeComponent();
}
}
public class RichTextBoxEditingControl : RichTextBoxControl,
IDataGridViewEditingControl
{
// Bunches of code to implement the IDataGridViewEditingControl
interface.
// Influenced by the MSDN DateTIme Calendar sample.
// ...
}
Any suggestions on where the lost character is going to and, more
importantly, how I can get it into the RichTextBox?