Solved

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

Posted on 2011-03-08
1
268 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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now