All
I am working with a DataGrid and a form consisting of a number of text,
checkbox, combobox controls, all bound to the same datatable. When I click
on my "New" button, I create a new row, make it the current row, and allow
the user to make changes in the form. If the user desires to cancel, they
can click the "Cancel Changes" button. Here is where my problems start.
Once the Cancel Changes button is clicked, the bindings on the form appear
to be permanently lost until I close and re-open the form. I have attached
the relevant portions of the New and Cancel button Click Event routines as
well as a representative portion of the binding initializations . Note that
I only bind the controls at form startup.
Can anyone tell me what I am doing wrong here?
TIA
Ron L
Private Sub BtnNew_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) _
Handles _btnNew.Click
....
' Create a new row in the data table and change the List Tab's
filter so that the new row is the selected item
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable)
Dim dr As DataRow = dt.NewRow
dr.Item("PPDID" ) = "NewPPD"
dt.Rows.Add(dr)
CType(cm.List, DataView).RowFi lter = "PPDID = 'NewPPD'"
....
End Sub
Private Sub CancelChanges(B yVal sender As System.Object, ByVal e As
System.EventArg s) _
Handles _btnCancel.Clic k
Dim cm As CurrencyManager
Dim drv, newRow As DataRowView
Dim permLevel As Integer
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable)
dt.RejectChange s()
' reset the previously selected ID.
_listCtlr.SetCu rrentRow(_listS electedID)
drv = CType(cm.List,
DataView).Item( _ppdctlr.ListGr id.CurrentRowIn dex)
permLevel = PermissionLevel (drv)
....
End Sub
Private Sub BindUserControl s()
Dim dt As DataTable = _ppdctlr.ListGr id.DataSource
_txtPPDID.DataB indings.Add("te xt", dt, "PPDID")
_txtGlobalID.Da taBindings.Add( "text", dt, "GlobalID")
_txtDuplicateOf .DataBindings.A dd("text", dt, "DuplicateO f")
_txtCPRRequestS ubmitted.DataBi ndings.Add("tex t", dt,
"CPRRequestedDa te")
_cbCPRRequired. DataBindings.Ad d("Checked", dt, "CPRRequire d")
_cbDPRRequired. DataBindings.Ad d("Checked", dt, "DPRRequire d")
_txtTitle.DataB indings.Add("te xt", dt, "Title")
_txtModDate.Dat aBindings.Add(" text", dt, "ModifiedDa te")
_cboType.DataBi ndings.Add("tex t", dt, "Type")
_cboProblemArea .DataBindings.A dd("text", dt, "ProblemAre a")
....
End Sub 14 1733
Ron,
I don't see direct the error, however does this work. Private Sub CancelChanges(B yVal sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnCancel.Clic k Dim cm As CurrencyManager Dim drv, newRow As DataRowView Dim permLevel As Integer
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) dt.RejectChange s()
' reset the previously selected ID. _listCtlr.SetCu rrentRow(_listS electedID) drv = CType(cm.List, DataView).Item( _ppdctlr.ListGr id.CurrentRowIn dex)
That cm (currencymanage r is just an address in my opinon without any
reference in it).
Cor
Cor
Thanks for the response. My Bad, the assignment to cm was in the code I cut
for clarity. The following line is in my code just after the
dt.RejectChange s line:
cm =
CType(_ppdctlr. ListGrid.Bindin gContext(CType( _ppdctlr.ListGr id.DataSource,
DataTable)), CurrencyManager )
Basically, my problem appears to be that the bindings are lost when the
changes are cancelled.
Ron L
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Ow******** ******@TK2MSFTN GP14.phx.gbl... Ron,
I don't see direct the error, however does this work.
Private Sub CancelChanges(B yVal sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnCancel.Clic k Dim cm As CurrencyManager Dim drv, newRow As DataRowView Dim permLevel As Integer
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) dt.RejectChange s()
' reset the previously selected ID. _listCtlr.SetCu rrentRow(_listS electedID) drv = CType(cm.List, DataView).Item( _ppdctlr.ListGr id.CurrentRowIn dex)
That cm (currencymanage r is just an address in my opinon without any reference in it).
Cor
Hi,
"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:es******** ******@TK2MSFTN GP14.phx.gbl... All
I am working with a DataGrid and a form consisting of a number of text, checkbox, combobox controls, all bound to the same datatable. When I click on my "New" button, I create a new row, make it the current row, and allow the user to make changes in the form. If the user desires to cancel, they can click the "Cancel Changes" button. Here is where my problems start. Once the Cancel Changes button is clicked, the bindings on the form appear to be permanently lost until I close and re-open the form. I have attached the relevant portions of the New and Cancel button Click Event routines as well as a representative portion of the binding initializations . Note that I only bind the controls at form startup.
Can anyone tell me what I am doing wrong here?
Did you already set default values for the fields that are bound to
CheckBox, CheckBox can't handle null values (common for new rows) and may
crash the binding, eg.:
dt.Columns( "DPRRequired"). DefaultValue = false
dt.Columns( "CPRRequired"). DefaultValue = false
Instead you could probely also set the default values after you create the
new row (dt.NewRow), *but* before you add it to the Rows collection.
I know you are not using CurrencyManager .AddNew but the problem with
CheckBox is described here: http://support.microsoft.com/default...b;en-us;326440
hth,
greetings TIA Ron L Private Sub BtnNew_Click(By Val sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnNew.Click ... ' Create a new row in the data table and change the List Tab's filter so that the new row is the selected item Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) Dim dr As DataRow = dt.NewRow dr.Item("PPDID" ) = "NewPPD" dt.Rows.Add(dr) CType(cm.List, DataView).RowFi lter = "PPDID = 'NewPPD'" ... End Sub
Private Sub CancelChanges(B yVal sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnCancel.Clic k Dim cm As CurrencyManager Dim drv, newRow As DataRowView Dim permLevel As Integer
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) dt.RejectChange s()
' reset the previously selected ID. _listCtlr.SetCu rrentRow(_listS electedID) drv = CType(cm.List, DataView).Item( _ppdctlr.ListGr id.CurrentRowIn dex) permLevel = PermissionLevel (drv) ... End Sub
Private Sub BindUserControl s() Dim dt As DataTable = _ppdctlr.ListGr id.DataSource
_txtPPDID.DataB indings.Add("te xt", dt, "PPDID") _txtGlobalID.Da taBindings.Add( "text", dt, "GlobalID") _txtDuplicateOf .DataBindings.A dd("text", dt, "DuplicateO f") _txtCPRRequestS ubmitted.DataBi ndings.Add("tex t", dt, "CPRRequestedDa te") _cbCPRRequired. DataBindings.Ad d("Checked", dt, "CPRRequire d") _cbDPRRequired. DataBindings.Ad d("Checked", dt, "DPRRequire d") _txtTitle.DataB indings.Add("te xt", dt, "Title") _txtModDate.Dat aBindings.Add(" text", dt, "ModifiedDa te") _cboType.DataBi ndings.Add("tex t", dt, "Type") _cboProblemArea .DataBindings.A dd("text", dt, "ProblemAre a") ... End Sub
Bart
Thanks for the response. I will give that a try.
Ron L
"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Hi,
"Ron L" <ro**@bogus.Add ress.com> wrote in message news:es******** ******@TK2MSFTN GP14.phx.gbl... All
I am working with a DataGrid and a form consisting of a number of text, checkbox, combobox controls, all bound to the same datatable. When I click on my "New" button, I create a new row, make it the current row, and allow the user to make changes in the form. If the user desires to cancel, they can click the "Cancel Changes" button. Here is where my problems start. Once the Cancel Changes button is clicked, the bindings on the form appear to be permanently lost until I close and re-open the form. I have attached the relevant portions of the New and Cancel button Click Event routines as well as a representative portion of the binding initializations . Note that I only bind the controls at form startup.
Can anyone tell me what I am doing wrong here?
Did you already set default values for the fields that are bound to CheckBox, CheckBox can't handle null values (common for new rows) and may crash the binding, eg.:
dt.Columns( "DPRRequired"). DefaultValue = false dt.Columns( "CPRRequired"). DefaultValue = false
Instead you could probely also set the default values after you create the new row (dt.NewRow), *but* before you add it to the Rows collection.
I know you are not using CurrencyManager .AddNew but the problem with CheckBox is described here: http://support.microsoft.com/default...b;en-us;326440
hth, greetings
TIA Ron L Private Sub BtnNew_Click(By Val sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnNew.Click ... ' Create a new row in the data table and change the List Tab's filter so that the new row is the selected item Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) Dim dr As DataRow = dt.NewRow dr.Item("PPDID" ) = "NewPPD" dt.Rows.Add(dr) CType(cm.List, DataView).RowFi lter = "PPDID = 'NewPPD'" ... End Sub
Private Sub CancelChanges(B yVal sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnCancel.Clic k Dim cm As CurrencyManager Dim drv, newRow As DataRowView Dim permLevel As Integer
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) dt.RejectChange s()
' reset the previously selected ID. _listCtlr.SetCu rrentRow(_listS electedID) drv = CType(cm.List, DataView).Item( _ppdctlr.ListGr id.CurrentRowIn dex) permLevel = PermissionLevel (drv) ... End Sub
Private Sub BindUserControl s() Dim dt As DataTable = _ppdctlr.ListGr id.DataSource
_txtPPDID.DataB indings.Add("te xt", dt, "PPDID") _txtGlobalID.Da taBindings.Add( "text", dt, "GlobalID") _txtDuplicateOf .DataBindings.A dd("text", dt, "DuplicateO f") _txtCPRRequestS ubmitted.DataBi ndings.Add("tex t", dt, "CPRRequestedDa te") _cbCPRRequired. DataBindings.Ad d("Checked", dt, "CPRRequire d") _cbDPRRequired. DataBindings.Ad d("Checked", dt, "DPRRequire d") _txtTitle.DataB indings.Add("te xt", dt, "Title") _txtModDate.Dat aBindings.Add(" text", dt, "ModifiedDa te") _cboType.DataBi ndings.Add("tex t", dt, "Type") _cboProblemArea .DataBindings.A dd("text", dt, "ProblemAre a") ... End Sub
Ron,
May I try to make it for me more clearer.
You add a datarow.
That is in the table the row
dt.rows(count-1)
I would in this remove or delete that datarow again when it is canceled,
what is in this action the same because it is an added row.
Cor
The same is that delete or remove in this case. A little bit unclear when I
have read it back.
Cor
I have tried using both the .RejectChanges method and row.Delete method, and
both have the same effect - my form's fields are empty and won't bind when
another row is selected in the list.
Ron L
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:eO******** *****@TK2MSFTNG P12.phx.gbl... The same is that delete or remove in this case. A little bit unclear when I have read it back.
Bart
Thanks for the thought, but that was apparently not the problem. I put in
the DefaultValues on each of those columns and still have the same results.
Ron L
"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Hi,
"Ron L" <ro**@bogus.Add ress.com> wrote in message news:es******** ******@TK2MSFTN GP14.phx.gbl... All
I am working with a DataGrid and a form consisting of a number of text, checkbox, combobox controls, all bound to the same datatable. When I click on my "New" button, I create a new row, make it the current row, and allow the user to make changes in the form. If the user desires to cancel, they can click the "Cancel Changes" button. Here is where my problems start. Once the Cancel Changes button is clicked, the bindings on the form appear to be permanently lost until I close and re-open the form. I have attached the relevant portions of the New and Cancel button Click Event routines as well as a representative portion of the binding initializations . Note that I only bind the controls at form startup.
Can anyone tell me what I am doing wrong here?
Did you already set default values for the fields that are bound to CheckBox, CheckBox can't handle null values (common for new rows) and may crash the binding, eg.:
dt.Columns( "DPRRequired"). DefaultValue = false dt.Columns( "CPRRequired"). DefaultValue = false
Instead you could probely also set the default values after you create the new row (dt.NewRow), *but* before you add it to the Rows collection.
I know you are not using CurrencyManager .AddNew but the problem with CheckBox is described here: http://support.microsoft.com/default...b;en-us;326440
hth, greetings
TIA Ron L Private Sub BtnNew_Click(By Val sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnNew.Click ... ' Create a new row in the data table and change the List Tab's filter so that the new row is the selected item Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) Dim dr As DataRow = dt.NewRow dr.Item("PPDID" ) = "NewPPD" dt.Rows.Add(dr) CType(cm.List, DataView).RowFi lter = "PPDID = 'NewPPD'" ... End Sub
Private Sub CancelChanges(B yVal sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnCancel.Clic k Dim cm As CurrencyManager Dim drv, newRow As DataRowView Dim permLevel As Integer
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) dt.RejectChange s()
' reset the previously selected ID. _listCtlr.SetCu rrentRow(_listS electedID) drv = CType(cm.List, DataView).Item( _ppdctlr.ListGr id.CurrentRowIn dex) permLevel = PermissionLevel (drv) ... End Sub
Private Sub BindUserControl s() Dim dt As DataTable = _ppdctlr.ListGr id.DataSource
_txtPPDID.DataB indings.Add("te xt", dt, "PPDID") _txtGlobalID.Da taBindings.Add( "text", dt, "GlobalID") _txtDuplicateOf .DataBindings.A dd("text", dt, "DuplicateO f") _txtCPRRequestS ubmitted.DataBi ndings.Add("tex t", dt, "CPRRequestedDa te") _cbCPRRequired. DataBindings.Ad d("Checked", dt, "CPRRequire d") _cbDPRRequired. DataBindings.Ad d("Checked", dt, "DPRRequire d") _txtTitle.DataB indings.Add("te xt", dt, "Title") _txtModDate.Dat aBindings.Add(" text", dt, "ModifiedDa te") _cboType.DataBi ndings.Add("tex t", dt, "Type") _cboProblemArea .DataBindings.A dd("text", dt, "ProblemAre a") ... End Sub
Hi Ron,
What exactly do you mean by bindings are lost?
You can't create new rows?
Do you realize that calling dt.RejectChange s will remove all rows that
aren't yet stored in database (DataRowState.A dded) and cancel all other
changes?
Is this the answer?
--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:es******** ******@TK2MSFTN GP14.phx.gbl... All
I am working with a DataGrid and a form consisting of a number of text, checkbox, combobox controls, all bound to the same datatable. When I click on my "New" button, I create a new row, make it the current row, and allow the user to make changes in the form. If the user desires to cancel, they can click the "Cancel Changes" button. Here is where my problems start. Once the Cancel Changes button is clicked, the bindings on the form appear to be permanently lost until I close and re-open the form. I have attached the relevant portions of the New and Cancel button Click Event routines as well as a representative portion of the binding initializations . Note that I only bind the controls at form startup.
Can anyone tell me what I am doing wrong here?
TIA Ron L Private Sub BtnNew_Click(By Val sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnNew.Click ... ' Create a new row in the data table and change the List Tab's filter so that the new row is the selected item Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) Dim dr As DataRow = dt.NewRow dr.Item("PPDID" ) = "NewPPD" dt.Rows.Add(dr) CType(cm.List, DataView).RowFi lter = "PPDID = 'NewPPD'" ... End Sub
Private Sub CancelChanges(B yVal sender As System.Object, ByVal e As System.EventArg s) _ Handles _btnCancel.Clic k Dim cm As CurrencyManager Dim drv, newRow As DataRowView Dim permLevel As Integer
Dim dt As DataTable = CType(_ppdctlr. ListGrid.DataSo urce, DataTable) dt.RejectChange s()
' reset the previously selected ID. _listCtlr.SetCu rrentRow(_listS electedID) drv = CType(cm.List, DataView).Item( _ppdctlr.ListGr id.CurrentRowIn dex) permLevel = PermissionLevel (drv) ... End Sub
Private Sub BindUserControl s() Dim dt As DataTable = _ppdctlr.ListGr id.DataSource
_txtPPDID.DataB indings.Add("te xt", dt, "PPDID") _txtGlobalID.Da taBindings.Add( "text", dt, "GlobalID") _txtDuplicateOf .DataBindings.A dd("text", dt, "DuplicateO f") _txtCPRRequestS ubmitted.DataBi ndings.Add("tex t", dt, "CPRRequestedDa te") _cbCPRRequired. DataBindings.Ad d("Checked", dt, "CPRRequire d") _cbDPRRequired. DataBindings.Ad d("Checked", dt, "DPRRequire d") _txtTitle.DataB indings.Add("te xt", dt, "Title") _txtModDate.Dat aBindings.Add(" text", dt, "ModifiedDa te") _cboType.DataBi ndings.Add("tex t", dt, "Type") _cboProblemArea .DataBindings.A dd("text", dt, "ProblemAre a") ... End Sub
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Thompson |
last post by:
Riverbank Computing is pleased to announce the release of PyQt v3.14 available
from http://www.riverbankcomputing.co.uk/.
Changes since the last release include support for QScintilla v1.5.
PyQt is a comprehensive set of Qt bindings for the Python programming language
and supports the same platforms as Qt. Like Qt, PyQt is available under...
|
by: Arthur Chereau |
last post by:
Hi,
I'm trying to setup viewcvs to work with subversion 1.2.0 on Linux with
Python 2.4.1. The last viewcvs (from CVS) needs subversion python
bindings. I installed swig and built subversion from source with it.
Everything works fine until I try to build the Python bindings.
When I try "make swig-py" I get the following, Python related,...
|
by: MajorTom |
last post by:
Hello
I need help. I have a datagrid that have a dataview as datasource.
in the keyup event of one textbox I use dataview.rowfilter = some.text;
when the condition of my rowfilter return some rows, everything works fine.
At the point that the rows returned by the rowfilter is cero (0), the
datagrid don't get the rows even if I use a...
|
by: Chuck Bowling |
last post by:
I have a typed collection bound to some form components. When information in
the dataset changes I want to mark it as dirty so that I can save it when
the form closes. The BindingManager.CurrentChanged event looks like the
perfect place to do this but it turns out that CurrentChanged also fires
when ever BindingManager.Position changes. I'm...
|
by: Marc Gravell |
last post by:
In the following example, the Bindings don't update the UI if the property
change is triggered from the non-UI thread - see the async button - from the
listbox contents (and observation) the change to the object has occurred
correctly; have I got a foobar somewhere, or is this the expected behaviour?
I can "fix" it by adding an additional few...
| |
by: AlonR |
last post by:
Hi,
We're experiencing random user sessions losses on our web applications,
and are researching for any useful information which may shed light on
this problem.
Environment:
In our company, we're developing a web product based on ASP.NET 2.0, in
conjunction with Oracle database over ADO.NET and external COM objects
|
by: Kirill Simonov |
last post by:
Hi,
I've written a pure Python module, which could optionally use an
external C library. The external library is not required to be on the
user computer however, so I'd like not to build the bindings by default,
but allow a user to turn the build on by specifying some parameter to
`setup.py`. Basically, it should work like
./configure...
|
by: Matteo Bertini |
last post by:
#### PyQt3Support - Python bindings for Qt3Support ####
http://www.develer.com/oss/PyQt3Support
#### What is this?
PyQt3Support is an extension to PyQt4 that adds bindings to Qt's
Qt3Support library for usage from the Python language.
This is very helpful to migrate existing PyQt3 applications to PyQt4.
|
by: Jason Yamada-Hanff |
last post by:
Hi all,
I'm working on a project that would benefit very much from Python
Freetype2 bindings (the Fonty Python project). I don't want to
duplicate efforts and wrap the library again if we don't have to.
Interestingly, it seems like there have been lots of attempts at doing
this.
Generally, there are:
ft2 -...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |