Solved

Adding a new row to table in a windows forms application.

Posted on 2011-03-08
1
277 Views
Last Modified: 2012-05-11
I'm starting to use Visual Studio to create a Windows Forms application. I've just started.
I'm using C#. Visual Studio 2010.

I used Delphi since version 1, and I feel a bit lost... no, totally lost, regarding to all data access related in Visual Studio.

In Delphi, for adding a record I used to call MyTable.Insert(), which would clear the content of my TDBEdit's controls, the fill them with data and a button with a MyTable.Post(); to save the data.

Well, that's mean that only two lines of code are required to insert a new record in a table with Delphi.
In Visual Studio, I have no idea, but I'm guessing is not that simple.

So, the first thing I want to do, is to "emulate" this Delphi behavior.
I have my text controls already bound, and they show the first row in my table (in Sql),  I added a button with a "New" caption, which I want to clear the current row data to allow entry for new data.

How do I do that? :(




0
Comment
Question by:fischermx
1 Comment
 
LVL 7

Accepted Solution

by:
jdavistx earned 500 total points
ID: 35074649
There's a couple different ways you could achieve this, but you may want to take a look at the CurrencyManager

http://msdn.microsoft.com/en-us/library/system.windows.forms.currencymanager.aspx

I assume you're wanting to append a new row, and not necessarily clear the current active row?

You could append a new blank row to your DataTable using:
myDataTable.Rows.Add(myDataTable.NewRow())

Open in new window

0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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