Reading cells value from DataGridView while in edit mode?

  • Thread starter Thread starter Sonnich Jensen
  • Start date Start date
S

Sonnich Jensen

Hi all

I want to read real time what the user in entering when the user enters something into a DataGridView. I can get the keys pressed, but I have no idea what might be there - so that is not enough

How do I get this?

WBR
Sonnich
 
El miércoles, 17 de diciembre de 2014 16:21:22 UTC+1, Sonnich Jensen escribió:
Hi all

I want to read real time what the user in entering when the user enters something into a DataGridView. I can get the keys pressed, but I have no idea what might be there - so that is not enough

How do I get this?

WBR
Sonnich

using JQuery I would do something similar to:

var enteredValue = $(document.activeElement).val();

if youd dont want to use it:

var focusedElement = document.activeElement;
var enteredValue = focusedElement.value;

Note 1: It is supposed that focusedElement is an input. Otherwise, check for the element type and get the right property.
Note 2: Warning, untested. IMHO should work :-P
 
El miércoles, 17 de diciembre de 2014 16:21:22 UTC+1, Sonnich Jensen escribió:

using JQuery I would do something similar to:

var enteredValue = $(document.activeElement).val();

if youd dont want to use it:

var focusedElement = document.activeElement;
var enteredValue = focusedElement.value;

Note 1: It is supposed that focusedElement is an input. Otherwise, check for the element type and get the right property.
Note 2: Warning, untested. IMHO should work :-P

This works

// enable related
bool newValue = (m_Row!=0);
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())["HeaderRow"];
ReadOnlyAttribute attrib = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)];
FieldInfo isReadOnly = attrib.GetType().GetField("isReadOnly", BindingFlags.NonPublic | BindingFlags.Instance);
isReadOnly.SetValue(attrib, newValue);
 
Back
Top