all groups > visual studio .net general > february 2007 >
You're in the

visual studio .net general

group:

Creating a new row in Datagridview



Creating a new row in Datagridview Komandur Kannan
2/25/2007 6:13:15 AM
visual studio .net general: Hi

Platform
vb.Net 2005 framework 2.0
Problem
I am trying to create a new row programtically in datagridview on the
time of cell leave.
example :
dgv.Rows.Add()
where dgv is the datagridview
When I do on the time of runtime the CLR throws an exception saying
"This is not allowed in this part of this code"

Parameswaran.N

Re: Creating a new row in Datagridview pvdg42
2/25/2007 11:53:01 AM

[quoted text, click to view]
Please provide more detailed information or clarification.

What are the pertinent property settings for the DataGridView, ReadOnly,
AllowUserToAddRows, etc?

Is this DataGridView data-bound by any chance?

Please accurately and completely quote the exception message, including the
exception type in the title bar.

Information above needed as issue replication attempts have failed based on
information provided.

RE: Creating a new row in Datagridview v-lliu NO[at]SPAM online.microsoft.com
4/2/2007 12:00:00 AM
Hi Komandur,

Based on my understanding, you'd like to add a new row in a DataGridView
when the focus leaves the current cell. If I'm off base, please feel free
to let me know.

I performed a test calling the DataGridView.Rows.Add method in the
CellLeave event handler. The result is that an exception occurs when this
method is called--'Operation cannot be performed in this event handler'.

Could you tell me why you'd like to add a new row in the DataGridView when
the focus leaves the current cell? Could you please explain your scenario?

Only if I understand your problem, I may provide you with possible
assistance.

Thank you for your understanding!

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Creating a new row in Datagridview Komandur Kannan
4/2/2007 10:56:01 PM
Hi Liu
Yes you are right,

My senario is
1. I ll validate a cell and create a new row on sucessful validation.
Row creation will not be done multiple time. I mean to say is threre are
three rows If the user is in the Last row then I sholud be able to create a
new row. If the user is in the first row and there is already the row been
creted then I ll not create a new row. Its a is vis versa .

I have handled the above senario in datagridview Keypress event. By
keeping a global boolean variable and created a new row.

Paramesaran.N





[quoted text, click to view]
RE: Creating a new row in Datagridview v-lliu NO[at]SPAM online.microsoft.com
4/3/2007 12:00:00 AM
Hi Paramesaran,

Thank you for your reply.

Do you mean that you have resolved your problem by handling the KeyPress
event of the DataGridView?

If you still need our assistance, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support
AddThis Social Bookmark Button