Solved

Application-Generated Column Values in DataGridView on New Record

Posted on 2007-12-06
3
583 Views
Last Modified: 2013-11-26
Application-Generated Column Values in DataGridView on New Record

I have a DataGridView which I am using to enter new records to a table with 5 columns/fields. However, values for two of the fields are generated by the program automatically using some algorith (not the database AutoNumber). As such, they should not be entered in the datagrid view. The idea is that when i click a "New Record" button, the corresponding two columns are disabled to disallow and the values generated and inserted in the respective cells. The user can then enter remainder of data.

My problem is how to have the Automatically generated values in the cells. Any hints?
0
Comment
Question by:gkinu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Author Comment

by:gkinu
ID: 20418672
I have realized that there is a VAlue property for each cell.

I am now using it as follows
           string GeneratedVal=SomeFunction();
           dataGridView1.Rows[0].Cells[3].Value = GeneratedVal;

Open in new window

0
 
LVL 1

Author Comment

by:gkinu
ID: 20418714
I have realized that there is a VAlue property for each cell.

I am now using it as follows
string GeneratedVal=SomeFunction();
dataGridView1.Rows[0].Cells[3].Value = GeneratedVal

Open in new window

0
 
LVL 6

Accepted Solution

by:
so3 earned 125 total points
ID: 20418730
you can also use this for setting a default value for the new row.

        private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            if (e.RowIndex >= 0)
                dataGridView1.Rows[e.RowIndex].Cells[3].Value = GeneratedVal;
        }

        private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
        {
            e.Row.Cells[3].Value = GeneratedVal;
        }
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c#, case, if 4 35
Learning About The VB.NET TableLayoutPanel Control 5 38
What is GIS method of Geometry data type? 6 28
Need Help With GDI+ in VB.Net 8 34
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question