Tuesday 21 April 2009

New row default values in DataGridView

I was looking for a nice way of displaying default values in a datagridview when a user creates a new row.

At first I looked at settings in the binding source but there wasn't anything that stood out. Then I looked att he table adapter again there wasn't anything I could use.

Finally I found that it was an event in dataGridView that was required. The event is called 'DefaultValuesNeeded'. It can be used to specify default values for any row in a DataGridView. It is fired when you create a new row in a DatagridView.

Below is a C# example from http://msdn.microsoft.com/en-us/library/b22t666e.aspx

private void dataGridView1_DefaultValuesNeeded(object sender,
System.Windows.Forms.DataGridViewRowEventArgs e)
e.Row.Cells["Region"].Value = "WA";
e.Row.Cells["City"].Value = "Redmond";
e.Row.Cells["PostalCode"].Value = "98052-6399";
e.Row.Cells["Region"].Value = "NA";
e.Row.Cells["Country"].Value = "USA";
e.Row.Cells["CustomerID"].Value = NewCustomerId();

Very useful and it is something I will be using a lot.


Unknown said...

I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.

java training in bangalore

Unknown said...

Excellent Article ...thank u for sharing, such a valuable content Learners to get good knowledge after reading this article... Java Training in Chennai

Unknown said...

Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep updating your blog... Java Training in Chennai

Unknown said...

It’s Good to share good things, Explained well...
RPA Training in Chennai | Blue Prism Training in Chennai

Stuartcent said...

It?s hard to find knowledgeable people on this topic, but you sound like you know what you?re talking about! Thanks esfileexplorerapkz.info

Mounika said...

After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
python training institute in chennai
python training in Bangalore
python training in pune
python training institute in chennai
python training in velachery
python online training

nilashri said...

This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot. 

Data science training in tambaram | Data Science training in anna nagar
Data Science training in chennai | Data science training in Bangalore
Data Science training in marathahalli | Data Science training in btm

srinithya said...

Excellent and useful blog admin, I would like to read more about this topic.
Blue Prism Training in Chennai | Blue Prism Training | Blue Prism Training Chennai | Blue Prism Training in Velachery | Blue Prism Training in Tambaram | UiPath Training in Chennai

Anonymous said...

Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.

angularjs Training in chennai
angularjs Training in chennai

angularjs-Training in tambaram

angularjs-Training in sholinganallur

angularjs-Training in velachery

Sumaya Manzoor said...

I was totally impressed with your content, keep posting.
Selenium training in chennai
Selenium training institute in Chennai
iOS Course Chennai
Digital Marketing Training in Chennai
android courses in chennai
android mobile apps development training in chennai

pavithra dass said...

Thank you for sharing such great information with us. I really appreciate everything that you’ve done here and am glad to know that you really care about the world that we live in.
Web Designing Course in chennai
PHP Training in Chennai
Web Designing Institute in Chennai
Web Designing Training Institutes in Chennai
PHP Course in Chennai
PHP Training Institute in Chennai

Anjali Siva said...

Informative post, thanks for taking time to share this page.
RPA Training in Chennai
RPA course
Robotics Process Automation Training in Chennai
RPA courses in Chennai
Blue Prism Training Chennai
UiPath Training in Chennai

Praylin S said...

Great blog! I was actually looking for these kinds of posts. I'm glad that I came across here. Looking forward for more informative posts from you.
Javascript Training in Chennai | Javascript Course | Javascript Training Institute in Chennai | Javascript Training Courses

Anoushka Sakthi said...

I am always searching online for articles that can help. There is obviously a lot to know about this. I think you made some good points
Selenium Training in Chennai
Selenium Training
iOS Training in Chennai
French Classes in Chennai
Big Data Training in Chennai
web designing course in chennai
web designing training in chennai

priya said...

I am really impressed with your efforts and really pleased to visit this post.
Microsoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training

priya said...

From your discussion I have understood that which will be better for me and which is easy to use. Really, I have liked your brilliant discussion. I will comThis is great helping material for every one visitor. You have done a great responsible person. i want to say thanks owner of this blog.
Microsoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training

Kevin Dellinger said...

Thanks for a marvelous posting! I quite enjoyed reading it, you could be a great author. I will ensure that I bookmark your blog and will come back in the future. I want to encourage you to continue your great job, have a nice afternoon! Click Here: Top Eight Quotes On Encryption Software & Eight Reasons You Will Never Be Able To How To Encrypt A Password For Free Like Steve Jobs

sandeep saxena said...

The way of describing about Technology is fine.Im really happy to read this.please share more like this.
DOT NET Training in Chennai
.Net course in chennai
Dot Net Training in Adyar
Html5 Training in Chennai
Html5 Courses in Chennai
QTP Training in Chennai
SAS Training in Chennai
DOT NET Training in Chennai

Priyanka said...

Attend The Python Training in Bangalore From ExcelR. Practical Python Training in Bangalore Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Python Training in Bangalore.

akalya said...


how to hack chromebook using crosh

hack tp link wifi username and password

brac ngo written test question

whatsapp ethical hacking

react js developer resume india

integer max value javascript

binatone wifi hack

a certain sum of money amounts to rs.1300 in 2 years and to rs. 1525 in 3.5 years. find the sum and the rate of interest

she spent most of her time tomusic

she most of her time tomusic

Softgen Infotech said...

I am happy for sharing on this blog its awesome blog I really impressed. thanks for sharing. Great efforts.

Join Cloud Computing Training in Bangalore at Softgen Infotech. Learn from Certified Professionals with 10+ Years of experience in Cloud Computing. Get 100% Placement Assistance. Placements in MNC after successful course completion.

raju said...

inplant training in chennai
inplant training in chennai for it.php
panama web hosting
syria hosting
services hosting
afghanistan shared web hosting
andorra web hosting
belarus web hosting
brunei darussalam hosting
inplant training in chennai

Maneesha said...

Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
courses on data analytics

dras said...

very nice post..
inplant training in chennai
inplant training in chennai
inplant training in chennai for it
Australia hosting
mexico web hosting
moldova web hosting
albania web hosting
andorra hosting
australia web hosting
denmark web hosting

shri said...

good post...!
internship in chennai for ece students
internships in chennai for cse students 2019
Inplant training in chennai
internship for eee students
free internship in chennai
eee internship in chennai
internship for ece students in chennai
inplant training in bangalore for cse
inplant training in bangalore
ccna training in chennai

aarthi said...

Excellent article.
Java training in Chennai

Java training in Bangalore

Java training in Hyderabad

Java Training in Coimbatore

Java Online Training

Anonymous said...

Nice content very helpful, It has a very important point which should be noted down. All points mentioned and very well written.Keep Posting & writing such content

AWS Online Training
Online AWS Certification Training

vé máy bay từ canada về Việt Nam said...

Mua vé máy bay tại Aivivu, tham khảo

chuyến bay từ trung quốc về việt nam hôm nay

đặt vé máy bay từ vinh đi sài gòn

vé máy bay chặng đà nẵng đi hà nội

giá vé máy bay đà nẵng đi đà lạt

vé máy bay eva từ mỹ về việt nam

Priya Rathod said...

Thanks for sharing the valuable information. This blog contains various good concept and ideas.
Python Training in Hyderabad
Python Course in Hyderabad

Priya Rathod said...

Hi, great... Tutorial is just awesome. It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.
AWS Training in Hyderabad
AWS Course in Hyderabad

Mrbk30 said...

Very Informative blog thank you for sharing. Keep sharing.

Best software training institute in Chennai. Make your career development the best by learning software courses.

php training institute in chennai
uipath training in chennai
rpa training in chennai

milka said...

Great post. keep sharing such a worthy information.
AWS course in Chennai

webmaster said...

Control & Protection Relays, Protection Relays
3 phase timer relay

shanitha said...

Nice Post... waiting for your next post. I have learned some new information. thanks for sharing.

performance marketing