Reading cells value from DataGridView while in edit mode?


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
 
Ad

Advertisements

B

bradbury9

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
 
Ad

Advertisements

S

Sonnich Jensen

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top