473,756 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# App - Overload CurrencyManager AddNew method

4 New Member
I have an application where I am using a DataGridView control to display DataTables stored in a DataSet. What I need to do is be able to prevent a user from adding a new if there is already a certain number of rows in the table. In addition, when the user deletes a row I need to be able to see the contents of that row and modify other rows in the DataTable appropriately.

From what I understand of the DataGridView controls interaction with its bound DataSet, it uses the a CurrencyManager to make changes to the table. I have tried to derive a class from CurrencyManger and create overloaded AddNew and RemoveAt methods, but I am not able to get the code to complie.

For Example:
public class NewCurrencyMana ger : CurrencyManager
{
public NewCurrencyMana ger(){
}

public override void AddNew()
{
if (this.Count > 15)
{
MessageBox.Show ("Out of Bounds");
}
else
base.AddNew();
}
}

Causes the error: error CS0143: The type 'System.Windows .Forms.Currency Manager' has no constructors defined

If the CurrencyManger is the right place to be looking, how should this be modified? If not, what approach should I be using?

Thanks
Sep 8 '07 #1
1 2063
r035198x
13,262 MVP
I have an application where I am using a DataGridView control to display DataTables stored in a DataSet. What I need to do is be able to prevent a user from adding a new if there is already a certain number of rows in the table. In addition, when the user deletes a row I need to be able to see the contents of that row and modify other rows in the DataTable appropriately.

From what I understand of the DataGridView controls interaction with its bound DataSet, it uses the a CurrencyManager to make changes to the table. I have tried to derive a class from CurrencyManger and create overloaded AddNew and RemoveAt methods, but I am not able to get the code to complie.

For Example:
public class NewCurrencyMana ger : CurrencyManager
{
public NewCurrencyMana ger(){
}

public override void AddNew()
{
if (this.Count > 15)
{
MessageBox.Show ("Out of Bounds");
}
else
base.AddNew();
}
}

Causes the error: error CS0143: The type 'System.Windows .Forms.Currency Manager' has no constructors defined

If the CurrencyManger is the right place to be looking, how should this be modified? If not, what approach should I be using?

Thanks
I doubt if you need to write your own CurrencyManager here. I think you only need to intercept the event called when you click the save button and do the validations at that point.
Sep 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
8091
by: Jan van Veldhuizen | last post by:
I have an application which is running fine with MS SqlServer, but it should be working with Oracle as weel. At a lot of places we rely upon the ADO Recordset to return incremented identity columns. Oralce however returns null or zero. How can this be fixed easily? Dim mConn As New ADODB.Connection Dim rs As New ADODB.Recordset
2
7089
by: Tim Marshall | last post by:
ODBC situation, Access 97, here is the code and I've marked where Access coughs up. The Access error message is 3027, can't update, database is read only. The Oracle table in question has a primary key defined as TEST_PK which is, of course, also an index: Private Sub btnSave_Click() Dim dbs As DAO.Database Dim rst As DAO.Recordset Dim qdf1 As DAO.QueryDef
4
2812
by: Kris Bethea via DotNetMonster.com | last post by:
Greetings, I have a VB.NET program that I am trying to convert to C# (my office decided that we are going to use C# from now on). I've only been working with C# for about a month now, so this has been quite the learning experience for me. The following code is from my VB.NET program and it selects the Call Number from my datagrid and then uses that information to populate another form.
3
1982
by: Mike Cooper | last post by:
I have been staring at the above error for over a week now! I have a an inherited data class looking like thus: Public Class DataGridBoolColumnInherit Inherits System.Windows.Forms.DataGridBoolColumn Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
4
4123
by: Jeremy | last post by:
I have a dataset containing 2 tables. A is the master table, B is a lookup table. There is a combobox bound to B, which updates a value in a FK field in A. my currencymanager is created thus: cmB= CType(frm.BindingContext(DsClient1.Tables("B")), CurrencyManager) The cbx has these settings: cbx.valuemember=b.primarykey cbx.displaymember=b.name
0
951
by: NetRacer | last post by:
hi, i have a form with a read-only datagrid and some other controls. the controls are bound to the same DataView as the datagrid. i want the user to select a row in the grid and then he can edit the data in the controls. i use currencymanager.position = datagrid.currentrowindex and for existing rows it works.
2
11480
by: Rich | last post by:
Hello, Following an example at http://www.vb-tips.com/dbpages.aspx?IA=DG (by Cor Lightert and Ken Tucker) on binding a dataRelation to a Datagridview for sqlClient, I was able to view rows in datagridview2 that corresponded to a selected row in datagridview1. Great article/example.
5
2089
by: hartley_aaron | last post by:
Hi, CurrencyManger has a method called AddNew which well create a new record in the data that it is bound to (ie a new datarow in a table). The new record has null values for all of its elements. What I would like to have is the ability to add a new record using the current values of the TextBox fields that have been bound to the datasource. I have tried various solutions to have the code edit the record using the current values...
0
3850
by: polocar | last post by:
Hi, I have noticed a strange behaviour of CurrencyManager objects in C# (I use Visual Studio 2005 Professional Edition). Suppose that you have a SQL Server database with 2 tables called "Cities" and "Persons", and that: "Cities" has 2 fields called "IDCity" and "NameCity" "Persons" has 3 fields called "IDPerson", "NamePerson" and "IDCityAddress" with "IDCity" and "IDCityAddress" fields relationed with the classical father-child relation...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.