|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrid Current PositionHi there,
I have th following Code to Get my Current Position and show it in a text box, as "Record 1 of 129" for Example. >> Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") + cmSystemUsers.Count.ToString) <<I have a Datagrid on my Winform, When I click on one of the rows in My datagrid I would like it to to indicate which record it is on e.g "Record 1 or 129", "Record 54 or 129", etc, etc, but it dosn`t update my lblNavLocation.Text. How would I get it to update whn I click on a row in my datagrid? Many Kind Thanks in Avance Regards NSC Me.Label1.Text = Me.DataGrid1.CurrentRowIndex.ToString() & " of " &
CType(Me.DataGrid1.DataSource, DataTable).Rows.Count - 1 -------------------------------------------------------------------------------- All that glitters has a high refractive index. www.mendhak.com Show quote "No_So_Clever" <NOSPAM@NOSPAM.net> wrote in message news:FP-cnTvDmcqWEu3eSa8jmw@karoo.co.uk... > Hi there, > > I have th following Code to Get my Current Position and show it in a text > box, as "Record 1 of 129" for Example. > > >> Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of > ") + cmSystemUsers.Count.ToString) << > > I have a Datagrid on my Winform, When I click on one of the rows in My > datagrid I would like it to to indicate which record it is on e.g "Record > 1 or 129", "Record 54 or 129", etc, etc, but it dosn`t update my > lblNavLocation.Text. How would I get it to update whn I click on a row in > my datagrid? > > Many Kind Thanks in Avance > Regards > NSC > Hi there,
Thanks for you reply. Im getting errors on: CType(Me.DataGrid1.DataSource, DataTable). I take it I change this to CType(me.dgdSystemUsers.dsSystemUsers, Passwords) dgdSystemUsers been my DataGrid, dsSysetmUsers been my DataSet and Passwords been my tabel. Is that right? Many Thanks Cheers NSC Show quote "S.M. Altaf [MVP]" <smaltaf@PLEASEDONTSPAMMEmsn.com> wrote in message news:%23hed%23tG5FHA.696@TK2MSFTNGP09.phx.gbl... > Me.Label1.Text = Me.DataGrid1.CurrentRowIndex.ToString() & " of " & > CType(Me.DataGrid1.DataSource, DataTable).Rows.Count - 1 > > -------------------------------------------------------------------------------- > All that glitters has a high refractive index. > www.mendhak.com > > > "No_So_Clever" <NOSPAM@NOSPAM.net> wrote in message > news:FP-cnTvDmcqWEu3eSa8jmw@karoo.co.uk... >> Hi there, >> >> I have th following Code to Get my Current Position and show it in a text >> box, as "Record 1 of 129" for Example. >> >> >> Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " >> >> of >> ") + cmSystemUsers.Count.ToString) << >> >> I have a Datagrid on my Winform, When I click on one of the rows in My >> datagrid I would like it to to indicate which record it is on e.g "Record >> 1 or 129", "Record 54 or 129", etc, etc, but it dosn`t update my >> lblNavLocation.Text. How would I get it to update whn I click on a row in >> my datagrid? >> >> Many Kind Thanks in Avance >> Regards >> NSC >> > > Hi,
Have a look of the currencymanager which mostly works the nices for this kind of problems. I changed it a little bit, so it should fits your prolbem now. http://www.vb-tips.com/default.aspx?ID=5f4a0f68-a3b6-4fc8-8aff-587f730fa118 I hope this helps, Cor Hi Cor,
Im Totally Confused now, why Currency Manager? I`ve been looking on the net and it seems i need to use DataGrid1.CurrentCellChanged also some place say use Dataviews. I don`t mean to knock you or your knowlage, or anything like that as im sure you know more than a mear newbie like myself but im just getting a little confused with everything at the moment:( I can understand looking at the DataGrid1.CurrentCellChanged but i can`t see anything on how to call it, or even any real coding for it which would work in my Mini App. Hope you can help. Many Thanks NSC Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:ugA%23NnH5FHA.1032@TK2MSFTNGP11.phx.gbl... > Hi, > > Have a look of the currencymanager which mostly works the nices for this > kind of problems. > > I changed it a little bit, so it should fits your prolbem now. > > http://www.vb-tips.com/default.aspx?ID=5f4a0f68-a3b6-4fc8-8aff-587f730fa118 > > I hope this helps, > > Cor > > Wizard,
My expirience is that this one works on places where the ones you name don't work. You can by the way that one as well use with the datatview inside the datatable. Than the datasource becomes dt.defaultview and the setting to cma as well dt.defaultview. (What I prefer, however I had written simple so I kept it as simple as possible). So try it and you see how easy it is in use. :-) CorHi Cor,
Sorry Now im really confused. How do I use this example on my project? You example dosn`t even have a datagrid on it:( Ive found this code that i`ve been playing with, but this on`t work either, searching the net for Datagrid, Textbox Binding with Currency Manager dosn`t throw me much help either:( I could post my full code if that would help?: Would it help of shold i use your example? Only thing with the example below is I don`t know how to call it:( I mean it sits there, but what triggers it when i click on a Row in my datagrid? Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) 'Get the row number on the DataGrid Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber 'Get the column number on the DataGrid Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber 'Get the content of the cell in the clicked cell on the Datagrid Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) 'Get the next cell content in the same row Dim cellvalue2 As Object = Nothing Try cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" Me.lblNavLocation.Text = cellvalue1.ToString() + " " + cellvalue2.ToString() Catch ex As Exception 'The exception occurs here because we increment iColnr+1 'Delete or comment MessageBox.Show-line you won´t get the error message MessageBox.Show("No further columns after the last column-->> " + ex.Message, "STOP") cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) 'Display this time (cellvalue2+cellvalue1) in TextBox Me.lblNavLocation.Text = cellvalue2.ToString() + " " + cellvalue1.ToString() End Try End Sub Many Thanks NSC Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... > Wizard, > > My expirience is that this one works on places where the ones you name > don't work. > > You can by the way that one as well use with the datatview inside the > datatable. > > Than the datasource becomes dt.defaultview and the setting to cma as well > dt.defaultview. (What I prefer, however I had written simple so I kept it > as simple as possible). > > So try it and you see how easy it is in use. > > :-) > > Cor > No so clever,
Create a new project. Drag a datagrid on the form Drag 3 textboxes on the form Go go the code Paste in the code from the webpage change at the error that you than sees datagridview in datagrid at the 4 other ones you change label in textbox start debug run You will see in textbox 3 all the time the current row possition. This should run and use less code than you are using now. Cor Show quote "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... > Hi Cor, > > Sorry Now im really confused. How do I use this example on my project? You > example dosn`t even have a datagrid on it:( > Ive found this code that i`ve been playing with, but this on`t work > either, searching the net for Datagrid, Textbox Binding with Currency > Manager dosn`t throw me much help either:( > I could post my full code if that would help?: > Would it help of shold i use your example? Only thing with the example > below is I don`t know how to call it:( I mean it sits there, but what > triggers it when i click on a Row in my datagrid? > > Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As > System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) > 'Get the row number on the DataGrid > Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber > 'Get the column number on the DataGrid > Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber > 'Get the content of the cell in the clicked cell on the Datagrid > Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) > 'Get the next cell content in the same row > Dim cellvalue2 As Object = Nothing > Try > cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) > 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" > Me.lblNavLocation.Text = cellvalue1.ToString() + " " + > cellvalue2.ToString() > Catch ex As Exception > 'The exception occurs here because we increment iColnr+1 > 'Delete or comment MessageBox.Show-line you won´t get the error message > MessageBox.Show("No further columns after the last column-->> " + > ex.Message, "STOP") > cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) > 'Display this time (cellvalue2+cellvalue1) in TextBox > Me.lblNavLocation.Text = cellvalue2.ToString() + " " + > cellvalue1.ToString() > End Try > End Sub > > Many Thanks > NSC > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >> Wizard, >> >> My expirience is that this one works on places where the ones you name >> don't work. >> >> You can by the way that one as well use with the datatview inside the >> datatable. >> >> Than the datasource becomes dt.defaultview and the setting to cma as well >> dt.defaultview. (What I prefer, however I had written simple so I kept it >> as simple as possible). >> >> So try it and you see how easy it is in use. >> >> :-) >> >> Cor >> > > Hi Cor,
Excellent - Got you Eample Working:))) Cheers Mate. OK So in My Project I need to Add: (I already have the following in my project) Dim WithEvents cmSystemUsers As CurrencyManager So Change: Dim cma As CurrencyManager = DirectCast(BindingContext(dt), CurrencyManager) To: cmSystemUsers.DirectCast(BindingContext(dt), CurrencyManager) (What would go in the Place of (DT) would this be my Dataset? i.e dsSystemUsers? Then add: AddHandler cma.CurrentChanged, AddressOf CurrentChanged - into my Forms Load How would I change: Label3.Text = DirectCast(sender, CurrencyManager).Position.ToString To be the Equivilant of : Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") + cmSystemUsers.Count.ToString) Many Thanks Again NSC Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:uNrIidU5FHA.2364@TK2MSFTNGP12.phx.gbl... > No so clever, > > Create a new project. > Drag a datagrid on the form > Drag 3 textboxes on the form > Go go the code > Paste in the code from the webpage > change at the error that you than sees datagridview in datagrid > at the 4 other ones you change label in textbox > start debug run > > You will see in textbox 3 all the time the current row possition. > > This should run and use less code than you are using now. > > Cor > > "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht > news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... >> Hi Cor, >> >> Sorry Now im really confused. How do I use this example on my project? >> You example dosn`t even have a datagrid on it:( >> Ive found this code that i`ve been playing with, but this on`t work >> either, searching the net for Datagrid, Textbox Binding with Currency >> Manager dosn`t throw me much help either:( >> I could post my full code if that would help?: >> Would it help of shold i use your example? Only thing with the example >> below is I don`t know how to call it:( I mean it sits there, but what >> triggers it when i click on a Row in my datagrid? >> >> Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As >> System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) >> 'Get the row number on the DataGrid >> Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber >> 'Get the column number on the DataGrid >> Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber >> 'Get the content of the cell in the clicked cell on the Datagrid >> Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) >> 'Get the next cell content in the same row >> Dim cellvalue2 As Object = Nothing >> Try >> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) >> 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" >> Me.lblNavLocation.Text = cellvalue1.ToString() + " " + >> cellvalue2.ToString() >> Catch ex As Exception >> 'The exception occurs here because we increment iColnr+1 >> 'Delete or comment MessageBox.Show-line you won´t get the error message >> MessageBox.Show("No further columns after the last column-->> " + >> ex.Message, "STOP") >> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) >> 'Display this time (cellvalue2+cellvalue1) in TextBox >> Me.lblNavLocation.Text = cellvalue2.ToString() + " " + >> cellvalue1.ToString() >> End Try >> End Sub >> >> Many Thanks >> NSC >> >> >> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >> news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >>> Wizard, >>> >>> My expirience is that this one works on places where the ones you name >>> don't work. >>> >>> You can by the way that one as well use with the datatview inside the >>> datatable. >>> >>> Than the datasource becomes dt.defaultview and the setting to cma as >>> well dt.defaultview. (What I prefer, however I had written simple so I >>> kept it as simple as possible). >>> >>> So try it and you see how easy it is in use. >>> >>> :-) >>> >>> Cor >>> >> >> > > Hi,
I wrote it already in the message I had send seperaat, however in the cma datasource is the same as your datasource from your datagrid. Cor Show quote "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht news:v9ucnS4Tg6KYue_eSa8jmw@karoo.co.uk... > Hi Cor, > > Excellent - Got you Eample Working:))) Cheers Mate. > > OK So in My Project I need to Add: > > (I already have the following in my project) Dim WithEvents cmSystemUsers > As CurrencyManager > > So Change: > > Dim cma As CurrencyManager = DirectCast(BindingContext(dt), > CurrencyManager) To: > > cmSystemUsers.DirectCast(BindingContext(dt), CurrencyManager) (What would > go in the Place of (DT) would this be my Dataset? i.e dsSystemUsers? > > Then add: AddHandler cma.CurrentChanged, AddressOf CurrentChanged - into > my Forms Load > > How would I change: Label3.Text = DirectCast(sender, > CurrencyManager).Position.ToString > > To be the Equivilant of : Me.lblNavLocation.Text = > (((cmSystemUsers.Position + 1).ToString + " of ") + > cmSystemUsers.Count.ToString) > > Many Thanks Again > NSC > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:uNrIidU5FHA.2364@TK2MSFTNGP12.phx.gbl... >> No so clever, >> >> Create a new project. >> Drag a datagrid on the form >> Drag 3 textboxes on the form >> Go go the code >> Paste in the code from the webpage >> change at the error that you than sees datagridview in datagrid >> at the 4 other ones you change label in textbox >> start debug run >> >> You will see in textbox 3 all the time the current row possition. >> >> This should run and use less code than you are using now. >> >> Cor >> >> "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht >> news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... >>> Hi Cor, >>> >>> Sorry Now im really confused. How do I use this example on my project? >>> You example dosn`t even have a datagrid on it:( >>> Ive found this code that i`ve been playing with, but this on`t work >>> either, searching the net for Datagrid, Textbox Binding with Currency >>> Manager dosn`t throw me much help either:( >>> I could post my full code if that would help?: >>> Would it help of shold i use your example? Only thing with the example >>> below is I don`t know how to call it:( I mean it sits there, but what >>> triggers it when i click on a Row in my datagrid? >>> >>> Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As >>> System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) >>> 'Get the row number on the DataGrid >>> Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber >>> 'Get the column number on the DataGrid >>> Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber >>> 'Get the content of the cell in the clicked cell on the Datagrid >>> Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) >>> 'Get the next cell content in the same row >>> Dim cellvalue2 As Object = Nothing >>> Try >>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) >>> 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" >>> Me.lblNavLocation.Text = cellvalue1.ToString() + " " + >>> cellvalue2.ToString() >>> Catch ex As Exception >>> 'The exception occurs here because we increment iColnr+1 >>> 'Delete or comment MessageBox.Show-line you won´t get the error message >>> MessageBox.Show("No further columns after the last column-->> " + >>> ex.Message, "STOP") >>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) >>> 'Display this time (cellvalue2+cellvalue1) in TextBox >>> Me.lblNavLocation.Text = cellvalue2.ToString() + " " + >>> cellvalue1.ToString() >>> End Try >>> End Sub >>> >>> Many Thanks >>> NSC >>> >>> >>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >>> news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >>>> Wizard, >>>> >>>> My expirience is that this one works on places where the ones you name >>>> don't work. >>>> >>>> You can by the way that one as well use with the datatview inside the >>>> datatable. >>>> >>>> Than the datasource becomes dt.defaultview and the setting to cma as >>>> well dt.defaultview. (What I prefer, however I had written simple so I >>>> kept it as simple as possible). >>>> >>>> So try it and you see how easy it is in use. >>>> >>>> :-) >>>> >>>> Cor >>>> >>> >>> >> >> > > Than to make it complete for if somebody wants to sort.
make from the two time dt on the page dt.defaultview DataGrid1.DataSource = dt.defaultview Dim cma As CurrencyManager = DirectCast(BindingContext(dt.defaultview), CurrencyManager) Cor Show quote "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... > Hi Cor, > > Sorry Now im really confused. How do I use this example on my project? You > example dosn`t even have a datagrid on it:( > Ive found this code that i`ve been playing with, but this on`t work > either, searching the net for Datagrid, Textbox Binding with Currency > Manager dosn`t throw me much help either:( > I could post my full code if that would help?: > Would it help of shold i use your example? Only thing with the example > below is I don`t know how to call it:( I mean it sits there, but what > triggers it when i click on a Row in my datagrid? > > Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As > System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) > 'Get the row number on the DataGrid > Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber > 'Get the column number on the DataGrid > Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber > 'Get the content of the cell in the clicked cell on the Datagrid > Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) > 'Get the next cell content in the same row > Dim cellvalue2 As Object = Nothing > Try > cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) > 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" > Me.lblNavLocation.Text = cellvalue1.ToString() + " " + > cellvalue2.ToString() > Catch ex As Exception > 'The exception occurs here because we increment iColnr+1 > 'Delete or comment MessageBox.Show-line you won´t get the error message > MessageBox.Show("No further columns after the last column-->> " + > ex.Message, "STOP") > cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) > 'Display this time (cellvalue2+cellvalue1) in TextBox > Me.lblNavLocation.Text = cellvalue2.ToString() + " " + > cellvalue1.ToString() > End Try > End Sub > > Many Thanks > NSC > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >> Wizard, >> >> My expirience is that this one works on places where the ones you name >> don't work. >> >> You can by the way that one as well use with the datatview inside the >> datatable. >> >> Than the datasource becomes dt.defaultview and the setting to cma as well >> dt.defaultview. (What I prefer, however I had written simple so I kept it >> as simple as possible). >> >> So try it and you see how easy it is in use. >> >> :-) >> >> Cor >> > > Hi Cor,
Sorry im been real stupid here. OK i have my App with your code in now and it works great when I lick on a row it chnged and tells me it Record "?" of Record "?" My Code is as follows:- 'Set Databining txtFirstname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_First") txtSurname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_Last") txtUsername.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Name") txtPassword.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Password") 'Initialize CurrencyManager for the table "Passwords" cmSystemUsers = Me.BindingContext(dsSystemUsers, "Passwords") cmSystemUsers = DirectCast(BindingContext(dsSystemUsers.Passwords), CurrencyManager) AddHandler cmSystemUsers.CurrentChanged, AddressOf CurrentChanged and also Private Sub dsSystemUsers_PositionChanged() Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") + cmSystemUsers.Count.ToString) End Sub Private Sub CurrentChanged(ByVal sender As Object, ByVal e As EventArgs) Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") + cmSystemUsers.Count.ToString) End Sub Now when I Insert a row and add the Data it just inserts Null into all my feilds:( When I check my database it hasn`t updated it with my inputs just empty fields. My Insert Code is: Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Try 'Clear out the current edits cmSystemUsers.EndCurrentEdit() cmSystemUsers.AddNew() Catch eEndEdit As System.Exception System.Windows.Forms.MessageBox.Show(eEndEdit.Message) End Try Me.dsSystemUsers_PositionChanged() txtFirstname.Enabled = True txtSurname.Enabled = True txtUsername.Enabled = True txtPassword.Enabled = True End Sub Then I click a button to call Me.UpdateDataSet. Also if I say Edit Row 33 and change the First_Name from Mark to Say Bob it makes the changes in Row 1, no mater what Row I change it always updates Row 1. I was thinking maybe I need to call the CurrentChanged in my Update code to get the correct Row but not sure if i do or even how. Also now I have CurrenctChanged do i Still need dsSystemUsers_PositionChanged() as I have got rid of my Navigation buttons on my Form. I'm Also not sure totally about my CurrentChanged as it hasn`t got the DirectCast bit in but i don`t know how to get that workin with my code. Also how would I call CurrentChanged from my Code as Me.CurrentChanged errors. Any Ideas? And Again Thnks for your Help So far. NSC Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OfENneU5FHA.3276@TK2MSFTNGP10.phx.gbl... > Than to make it complete for if somebody wants to sort. > > make from the two time dt on the page dt.defaultview > DataGrid1.DataSource = dt.defaultview > Dim cma As CurrencyManager = DirectCast(BindingContext(dt.defaultview), > CurrencyManager) > > Cor > > "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht > news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... >> Hi Cor, >> >> Sorry Now im really confused. How do I use this example on my project? >> You example dosn`t even have a datagrid on it:( >> Ive found this code that i`ve been playing with, but this on`t work >> either, searching the net for Datagrid, Textbox Binding with Currency >> Manager dosn`t throw me much help either:( >> I could post my full code if that would help?: >> Would it help of shold i use your example? Only thing with the example >> below is I don`t know how to call it:( I mean it sits there, but what >> triggers it when i click on a Row in my datagrid? >> >> Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As >> System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) >> 'Get the row number on the DataGrid >> Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber >> 'Get the column number on the DataGrid >> Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber >> 'Get the content of the cell in the clicked cell on the Datagrid >> Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) >> 'Get the next cell content in the same row >> Dim cellvalue2 As Object = Nothing >> Try >> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) >> 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" >> Me.lblNavLocation.Text = cellvalue1.ToString() + " " + >> cellvalue2.ToString() >> Catch ex As Exception >> 'The exception occurs here because we increment iColnr+1 >> 'Delete or comment MessageBox.Show-line you won´t get the error message >> MessageBox.Show("No further columns after the last column-->> " + >> ex.Message, "STOP") >> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) >> 'Display this time (cellvalue2+cellvalue1) in TextBox >> Me.lblNavLocation.Text = cellvalue2.ToString() + " " + >> cellvalue1.ToString() >> End Try >> End Sub >> >> Many Thanks >> NSC >> >> >> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >> news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >>> Wizard, >>> >>> My expirience is that this one works on places where the ones you name >>> don't work. >>> >>> You can by the way that one as well use with the datatview inside the >>> datatable. >>> >>> Than the datasource becomes dt.defaultview and the setting to cma as >>> well dt.defaultview. (What I prefer, however I had written simple so I >>> kept it as simple as possible). >>> >>> So try it and you see how easy it is in use. >>> >>> :-) >>> >>> Cor >>> >> >> > > Hi Cor,
Sorry but another prob i`ve noticed:( The Following Code: 'Set Datagrid Data Source dgdSystemUsers.DataSource = dsSystemUsers.Passwords 'dgdSystemUsers.SetDataBinding(dsSystemUsers, "Passwords") 'Set Databining txtFirstname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_First") txtSurname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_Last") txtUsername.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Name") txtPassword.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Password") 'Initialize CurrencyManager for the table "Passwords" cmSystemUsers = Me.BindingContext(dsSystemUsers, "Passwords") cmSystemUsers = DirectCast(BindingContext(dsSystemUsers.Passwords), CurrencyManager) AddHandler cmSystemUsers.CurrentChanged, AddressOf CurrentChanged When I have: 'dgdSystemUsers.SetDataBinding(dsSystemUsers, "Passwords") enabled, as I click from Row to Row it shows what record im on in my Nav.textBox. but doesn`t change my Texboxs tht are mapped to coloums in my table. If I disable that and Enable: txtFirstname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_First") txtSurname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_Last") txtUsername.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Name") txtPassword.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Password") It Changes my textbox`s but dosn`t upate my Nav.Texbox. If I enable both it tells me Bindings have Failed. Any Clues or Ideas? Would it be better if I mailed you my or put it somehwhere on the Web? Many Thanks NSC Show quote "No_So_Clever" <NOSPAM@NOSPAM.net> wrote in message news:OYmdncmZLPNfpe_eSa8jmw@karoo.co.uk... > Hi Cor, > > Sorry im been real stupid here. OK i have my App with your code in now and > it works great when I lick on a row it chnged and tells me it Record "?" > of Record "?" > > My Code is as follows:- > > 'Set Databining > txtFirstname.DataBindings.Add("Text", dsSystemUsers, > "Passwords.User_First") > txtSurname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_Last") > txtUsername.DataBindings.Add("Text", dsSystemUsers, > "Passwords.Users_Name") > txtPassword.DataBindings.Add("Text", dsSystemUsers, > "Passwords.Users_Password") > > 'Initialize CurrencyManager for the table "Passwords" > cmSystemUsers = Me.BindingContext(dsSystemUsers, "Passwords") > cmSystemUsers = DirectCast(BindingContext(dsSystemUsers.Passwords), > CurrencyManager) > AddHandler cmSystemUsers.CurrentChanged, AddressOf CurrentChanged > and also > > Private Sub dsSystemUsers_PositionChanged() > Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") > + cmSystemUsers.Count.ToString) > End Sub > > Private Sub CurrentChanged(ByVal sender As Object, ByVal e As EventArgs) > Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") > + cmSystemUsers.Count.ToString) > End Sub > > Now when I Insert a row and add the Data it just inserts Null into all my > feilds:( When I check my database it hasn`t updated it with my inputs just > empty fields. > > My Insert Code is: > > Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnAdd.Click > Try > 'Clear out the current edits > cmSystemUsers.EndCurrentEdit() > cmSystemUsers.AddNew() > Catch eEndEdit As System.Exception > System.Windows.Forms.MessageBox.Show(eEndEdit.Message) > End Try > Me.dsSystemUsers_PositionChanged() > txtFirstname.Enabled = True > txtSurname.Enabled = True > txtUsername.Enabled = True > txtPassword.Enabled = True > End Sub > > Then I click a button to call Me.UpdateDataSet. Also if I say Edit Row 33 > and change the First_Name from Mark to Say Bob it makes the changes in Row > 1, no mater what Row I change it always updates Row 1. I was thinking > maybe I need to call the CurrentChanged in my Update code to get the > correct Row but not sure if i do or even how. Also now I have > CurrenctChanged do i Still need dsSystemUsers_PositionChanged() as I have > got rid of my Navigation buttons on my Form. I'm Also not sure totally > about my CurrentChanged as it hasn`t got the DirectCast bit in but i don`t > know how to get that workin with my code. Also how would I call > CurrentChanged from my Code as Me.CurrentChanged errors. > > Any Ideas? > And Again Thnks for your Help So far. > NSC > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:OfENneU5FHA.3276@TK2MSFTNGP10.phx.gbl... >> Than to make it complete for if somebody wants to sort. >> >> make from the two time dt on the page dt.defaultview >> DataGrid1.DataSource = dt.defaultview >> Dim cma As CurrencyManager = DirectCast(BindingContext(dt.defaultview), >> CurrencyManager) >> >> Cor >> >> "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht >> news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... >>> Hi Cor, >>> >>> Sorry Now im really confused. How do I use this example on my project? >>> You example dosn`t even have a datagrid on it:( >>> Ive found this code that i`ve been playing with, but this on`t work >>> either, searching the net for Datagrid, Textbox Binding with Currency >>> Manager dosn`t throw me much help either:( >>> I could post my full code if that would help?: >>> Would it help of shold i use your example? Only thing with the example >>> below is I don`t know how to call it:( I mean it sits there, but what >>> triggers it when i click on a Row in my datagrid? >>> >>> Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As >>> System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) >>> 'Get the row number on the DataGrid >>> Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber >>> 'Get the column number on the DataGrid >>> Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber >>> 'Get the content of the cell in the clicked cell on the Datagrid >>> Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) >>> 'Get the next cell content in the same row >>> Dim cellvalue2 As Object = Nothing >>> Try >>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) >>> 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" >>> Me.lblNavLocation.Text = cellvalue1.ToString() + " " + >>> cellvalue2.ToString() >>> Catch ex As Exception >>> 'The exception occurs here because we increment iColnr+1 >>> 'Delete or comment MessageBox.Show-line you won´t get the error message >>> MessageBox.Show("No further columns after the last column-->> " + >>> ex.Message, "STOP") >>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) >>> 'Display this time (cellvalue2+cellvalue1) in TextBox >>> Me.lblNavLocation.Text = cellvalue2.ToString() + " " + >>> cellvalue1.ToString() >>> End Try >>> End Sub >>> >>> Many Thanks >>> NSC >>> >>> >>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >>> news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >>>> Wizard, >>>> >>>> My expirience is that this one works on places where the ones you name >>>> don't work. >>>> >>>> You can by the way that one as well use with the datatview inside the >>>> datatable. >>>> >>>> Than the datasource becomes dt.defaultview and the setting to cma as >>>> well dt.defaultview. (What I prefer, however I had written simple so I >>>> kept it as simple as possible). >>>> >>>> So try it and you see how easy it is in use. >>>> >>>> :-) >>>> >>>> Cor >>>> >>> >>> >> >> > > No So Clever,
There is no need to sent all code, try it with snippets, if there is needed more than it is asked mostly. This is to much for a newsgroup. There is to much in it, but that you will see in future. Nevertheless. > cmSystemUsers.EndCurrentEdit() It adds always forever at the end of the datasource. Therefore you know that > cmSystemUsers.AddNew() you can add the key add thedatasource(thedatasource.Rowcount - 1)(KeyField) = theTnewKey I hope this helps, Cor Show quote "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht news:OYmdncmZLPNfpe_eSa8jmw@karoo.co.uk... > Hi Cor, > > Sorry im been real stupid here. OK i have my App with your code in now and > it works great when I lick on a row it chnged and tells me it Record "?" > of Record "?" > > My Code is as follows:- > > 'Set Databining > txtFirstname.DataBindings.Add("Text", dsSystemUsers, > "Passwords.User_First") > txtSurname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_Last") > txtUsername.DataBindings.Add("Text", dsSystemUsers, > "Passwords.Users_Name") > txtPassword.DataBindings.Add("Text", dsSystemUsers, > "Passwords.Users_Password") > > 'Initialize CurrencyManager for the table "Passwords" > cmSystemUsers = Me.BindingContext(dsSystemUsers, "Passwords") > cmSystemUsers = DirectCast(BindingContext(dsSystemUsers.Passwords), > CurrencyManager) > AddHandler cmSystemUsers.CurrentChanged, AddressOf CurrentChanged > and also > > Private Sub dsSystemUsers_PositionChanged() > Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") > + cmSystemUsers.Count.ToString) > End Sub > > Private Sub CurrentChanged(ByVal sender As Object, ByVal e As EventArgs) > Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") > + cmSystemUsers.Count.ToString) > End Sub > > Now when I Insert a row and add the Data it just inserts Null into all my > feilds:( When I check my database it hasn`t updated it with my inputs just > empty fields. > > My Insert Code is: > > Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnAdd.Click > Try > 'Clear out the current edits > cmSystemUsers.EndCurrentEdit() > cmSystemUsers.AddNew() > Catch eEndEdit As System.Exception > System.Windows.Forms.MessageBox.Show(eEndEdit.Message) > End Try > Me.dsSystemUsers_PositionChanged() > txtFirstname.Enabled = True > txtSurname.Enabled = True > txtUsername.Enabled = True > txtPassword.Enabled = True > End Sub > > Then I click a button to call Me.UpdateDataSet. Also if I say Edit Row 33 > and change the First_Name from Mark to Say Bob it makes the changes in Row > 1, no mater what Row I change it always updates Row 1. I was thinking > maybe I need to call the CurrentChanged in my Update code to get the > correct Row but not sure if i do or even how. Also now I have > CurrenctChanged do i Still need dsSystemUsers_PositionChanged() as I have > got rid of my Navigation buttons on my Form. I'm Also not sure totally > about my CurrentChanged as it hasn`t got the DirectCast bit in but i don`t > know how to get that workin with my code. Also how would I call > CurrentChanged from my Code as Me.CurrentChanged errors. > > Any Ideas? > And Again Thnks for your Help So far. > NSC > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:OfENneU5FHA.3276@TK2MSFTNGP10.phx.gbl... >> Than to make it complete for if somebody wants to sort. >> >> make from the two time dt on the page dt.defaultview >> DataGrid1.DataSource = dt.defaultview >> Dim cma As CurrencyManager = DirectCast(BindingContext(dt.defaultview), >> CurrencyManager) >> >> Cor >> >> "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht >> news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... >>> Hi Cor, >>> >>> Sorry Now im really confused. How do I use this example on my project? >>> You example dosn`t even have a datagrid on it:( >>> Ive found this code that i`ve been playing with, but this on`t work >>> either, searching the net for Datagrid, Textbox Binding with Currency >>> Manager dosn`t throw me much help either:( >>> I could post my full code if that would help?: >>> Would it help of shold i use your example? Only thing with the example >>> below is I don`t know how to call it:( I mean it sits there, but what >>> triggers it when i click on a Row in my datagrid? >>> >>> Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As >>> System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) >>> 'Get the row number on the DataGrid >>> Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber >>> 'Get the column number on the DataGrid >>> Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber >>> 'Get the content of the cell in the clicked cell on the Datagrid >>> Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) >>> 'Get the next cell content in the same row >>> Dim cellvalue2 As Object = Nothing >>> Try >>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) >>> 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" >>> Me.lblNavLocation.Text = cellvalue1.ToString() + " " + >>> cellvalue2.ToString() >>> Catch ex As Exception >>> 'The exception occurs here because we increment iColnr+1 >>> 'Delete or comment MessageBox.Show-line you won´t get the error message >>> MessageBox.Show("No further columns after the last column-->> " + >>> ex.Message, "STOP") >>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) >>> 'Display this time (cellvalue2+cellvalue1) in TextBox >>> Me.lblNavLocation.Text = cellvalue2.ToString() + " " + >>> cellvalue1.ToString() >>> End Try >>> End Sub >>> >>> Many Thanks >>> NSC >>> >>> >>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >>> news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >>>> Wizard, >>>> >>>> My expirience is that this one works on places where the ones you name >>>> don't work. >>>> >>>> You can by the way that one as well use with the datatview inside the >>>> datatable. >>>> >>>> Than the datasource becomes dt.defaultview and the setting to cma as >>>> well dt.defaultview. (What I prefer, however I had written simple so I >>>> kept it as simple as possible). >>>> >>>> So try it and you see how easy it is in use. >>>> >>>> :-) >>>> >>>> Cor >>>> >>> >>> >> >> > > Hi Cor,
OK i`ve gone back to very Basics with my Code: Private Sub frmSystemUsers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'File Datasets dsSystemUsers.EnforceConstraints = False Me.odcSystemUsers.Open() odaSystemUsers.Fill(dsSystemUsers) 'Set Datagrid Data Source dgdSystemUsers.DataSource = dsSystemUsers.Passwords 'Set Databining txtFirstname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_First") txtSurname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_Last") txtUsername.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Name") txtPassword.DataBindings.Add("Text", dsSystemUsers, "Passwords.Users_Password") 'Initialize CurrencyManager for the table "Passwords" cmSystemUsers = Me.BindingContext(dsSystemUsers, "Passwords") cmSystemUsers = DirectCast(BindingContext(dsSystemUsers.Passwords), CurrencyManager) AddHandler cmSystemUsers.CurrentChanged, AddressOf CurrentChanged Me.odcSystemUsers.Close() End Sub Private Sub CurrentChanged(ByVal sender As Object, ByVal e As EventArgs) Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of ") + cmSystemUsers.Count.ToString) End Sub Any Ideas why the Above won`t work, its OK and calls my CurrentChanged and tells me my Record of Record, but my Text Boxs don`t change when I click on a rown in my Grid. They simply Stay showing Row one:( Any Ideas Many Thanks NSC Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:uOVotcc5FHA.1464@tk2msftngp13.phx.gbl... > No So Clever, > > There is no need to sent all code, try it with snippets, if there is > needed more than it is asked mostly. This is to much for a newsgroup. > There is to much in it, but that you will see in future. > > Nevertheless. >> cmSystemUsers.EndCurrentEdit() >> cmSystemUsers.AddNew() > > It adds always forever at the end of the datasource. Therefore you know > that you can add the key add > thedatasource(thedatasource.Rowcount - 1)(KeyField) = theTnewKey > > I hope this helps, > > Cor > > > > "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht > news:OYmdncmZLPNfpe_eSa8jmw@karoo.co.uk... >> Hi Cor, >> >> Sorry im been real stupid here. OK i have my App with your code in now >> and it works great when I lick on a row it chnged and tells me it Record >> "?" of Record "?" >> >> My Code is as follows:- >> >> 'Set Databining >> txtFirstname.DataBindings.Add("Text", dsSystemUsers, >> "Passwords.User_First") >> txtSurname.DataBindings.Add("Text", dsSystemUsers, "Passwords.User_Last") >> txtUsername.DataBindings.Add("Text", dsSystemUsers, >> "Passwords.Users_Name") >> txtPassword.DataBindings.Add("Text", dsSystemUsers, >> "Passwords.Users_Password") >> >> 'Initialize CurrencyManager for the table "Passwords" >> cmSystemUsers = Me.BindingContext(dsSystemUsers, "Passwords") >> cmSystemUsers = DirectCast(BindingContext(dsSystemUsers.Passwords), >> CurrencyManager) >> AddHandler cmSystemUsers.CurrentChanged, AddressOf CurrentChanged >> and also >> >> Private Sub dsSystemUsers_PositionChanged() >> Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of >> ") + cmSystemUsers.Count.ToString) >> End Sub >> >> Private Sub CurrentChanged(ByVal sender As Object, ByVal e As EventArgs) >> Me.lblNavLocation.Text = (((cmSystemUsers.Position + 1).ToString + " of >> ") + cmSystemUsers.Count.ToString) >> End Sub >> >> Now when I Insert a row and add the Data it just inserts Null into all my >> feilds:( When I check my database it hasn`t updated it with my inputs >> just empty fields. >> >> My Insert Code is: >> >> Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As >> System.EventArgs) Handles btnAdd.Click >> Try >> 'Clear out the current edits >> cmSystemUsers.EndCurrentEdit() >> cmSystemUsers.AddNew() >> Catch eEndEdit As System.Exception >> System.Windows.Forms.MessageBox.Show(eEndEdit.Message) >> End Try >> Me.dsSystemUsers_PositionChanged() >> txtFirstname.Enabled = True >> txtSurname.Enabled = True >> txtUsername.Enabled = True >> txtPassword.Enabled = True >> End Sub >> >> Then I click a button to call Me.UpdateDataSet. Also if I say Edit Row 33 >> and change the First_Name from Mark to Say Bob it makes the changes in >> Row 1, no mater what Row I change it always updates Row 1. I was thinking >> maybe I need to call the CurrentChanged in my Update code to get the >> correct Row but not sure if i do or even how. Also now I have >> CurrenctChanged do i Still need dsSystemUsers_PositionChanged() as I have >> got rid of my Navigation buttons on my Form. I'm Also not sure totally >> about my CurrentChanged as it hasn`t got the DirectCast bit in but i >> don`t know how to get that workin with my code. Also how would I call >> CurrentChanged from my Code as Me.CurrentChanged errors. >> >> Any Ideas? >> And Again Thnks for your Help So far. >> NSC >> >> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >> news:OfENneU5FHA.3276@TK2MSFTNGP10.phx.gbl... >>> Than to make it complete for if somebody wants to sort. >>> >>> make from the two time dt on the page dt.defaultview >>> DataGrid1.DataSource = dt.defaultview >>> Dim cma As CurrencyManager = DirectCast(BindingContext(dt.defaultview), >>> CurrencyManager) >>> >>> Cor >>> >>> "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht >>> news:4b-cnc9fTo4Vhu_eSa8jmw@karoo.co.uk... >>>> Hi Cor, >>>> >>>> Sorry Now im really confused. How do I use this example on my project? >>>> You example dosn`t even have a datagrid on it:( >>>> Ive found this code that i`ve been playing with, but this on`t work >>>> either, searching the net for Datagrid, Textbox Binding with Currency >>>> Manager dosn`t throw me much help either:( >>>> I could post my full code if that would help?: >>>> Would it help of shold i use your example? Only thing with the example >>>> below is I don`t know how to call it:( I mean it sits there, but what >>>> triggers it when i click on a Row in my datagrid? >>>> >>>> Private Sub dgdSystemUsers_CurrentCellChanged(ByVal sender As >>>> System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) >>>> 'Get the row number on the DataGrid >>>> Dim iRownr As Integer = Me.dgdSystemUsers.CurrentCell.RowNumber >>>> 'Get the column number on the DataGrid >>>> Dim iColnr As Integer = Me.dgdSystemUsers.CurrentCell.ColumnNumber >>>> 'Get the content of the cell in the clicked cell on the Datagrid >>>> Dim cellvalue1 As Object = Me.dgdSystemUsers(iRownr, iColnr) >>>> 'Get the next cell content in the same row >>>> Dim cellvalue2 As Object = Nothing >>>> Try >>>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr + 1) >>>> 'Display (cellvalue1+cellvalue2) in TextBox "textBox1" >>>> Me.lblNavLocation.Text = cellvalue1.ToString() + " " + >>>> cellvalue2.ToString() >>>> Catch ex As Exception >>>> 'The exception occurs here because we increment iColnr+1 >>>> 'Delete or comment MessageBox.Show-line you won´t get the error message >>>> MessageBox.Show("No further columns after the last column-->> " + >>>> ex.Message, "STOP") >>>> cellvalue2 = Me.dgdSystemUsers(iRownr, iColnr - 1) >>>> 'Display this time (cellvalue2+cellvalue1) in TextBox >>>> Me.lblNavLocation.Text = cellvalue2.ToString() + " " + >>>> cellvalue1.ToString() >>>> End Try >>>> End Sub >>>> >>>> Many Thanks >>>> NSC >>>> >>>> >>>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >>>> news:e9yO4CJ5FHA.692@TK2MSFTNGP11.phx.gbl... >>>>> Wizard, >>>>> >>>>> My expirience is that this one works on places where the ones you name >>>>> don't work. >>>>> >>>>> You can by the way that one as well use with the datatview inside the >>>>> datatable. >>>>> >>>>> Than the datasource becomes dt.defaultview and the setting to cma as >>>>> well dt.defaultview. (What I prefer, however I had written simple so I >>>>> kept it as simple as possible). >>>>> >>>>> So try it and you see how easy it is in use. >>>>> >>>>> :-) >>>>> >>>>> Cor >>>>> >>>> >>>> >>> >>> >> >> > > Probably because your datagrid has another datasource than that you use in
the binding of the textboxes. dsSystemUsers.Passwords I hope this helps, Cor > 'Set Datagrid Data Source Cor> dgdSystemUsers.DataSource = dsSystemUsers.Passwords > 'Set Databining > txtFirstname.DataBindings.Add("Text", dsSystemUsers, > "Passwords.User_First") Hi Cor,
Thanks for you reply. Sorry im lost again. Both my Datasource`s are dsSystemUsers.Passwords.All I have on my App is 1 DataSet. Could you explain a bit more? Im very sorry about been sooooooo Stupid Cor, but im a newbie and really finding it hard to understand some of these things. I have some books on the way tho:) Many Thanks Si Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:Oninhap5FHA.2956@TK2MSFTNGP12.phx.gbl... > Probably because your datagrid has another datasource than that you use in > the binding of the textboxes. > > dsSystemUsers.Passwords > > I hope this helps, > > Cor > >> 'Set Datagrid Data Source >> dgdSystemUsers.DataSource = dsSystemUsers.Passwords >> 'Set Databining >> txtFirstname.DataBindings.Add("Text", dsSystemUsers, >> "Passwords.User_First") > > Cor > > Si,
No see as I showed you. You have Datagrid dsSystemUsers.Passwords Normal Controls: dsSystemUsers So in my opinion they have to be all Datagrid dsSystemUsers.Passwords (The table) :-) CorShow quote "NOT_SO_CLEVER" <t***@test.com> schreef in bericht news:uVUqvrp5FHA.1140@tk2msftngp13.phx.gbl... > Hi Cor, > > Thanks for you reply. Sorry im lost again. Both my Datasource`s are > dsSystemUsers.Passwords.All I have on my App is 1 DataSet. Could you > explain a bit more? > > Im very sorry about been sooooooo Stupid Cor, but im a newbie and really > finding it hard to understand some of these things. I have some books on > the way tho:) > > Many Thanks > Si > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:Oninhap5FHA.2956@TK2MSFTNGP12.phx.gbl... >> Probably because your datagrid has another datasource than that you use >> in the binding of the textboxes. >> >> dsSystemUsers.Passwords >> >> I hope this helps, >> >> Cor >> >>> 'Set Datagrid Data Source >>> dgdSystemUsers.DataSource = dsSystemUsers.Passwords >>> 'Set Databining >>> txtFirstname.DataBindings.Add("Text", dsSystemUsers, >>> "Passwords.User_First") >> >> Cor >> >> > > Excellent, Now its working, good im so daft:). Cheers for that Cor
Tell me if im been in pain now, but its just my insert code now thats not working:( You said "It adds always forever at the end of the datasource. Therefore you know that you can add the key add thedatasource(thedatasource.Rowcount - 1)(KeyField) = theTnewKey" So if my Insert code is: Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click cmSystemUsers.EndCurrentEdit() cmSystemUsers.AddNew() Me.dsSystemUsers_PositionChanged() txtFirstname.Enabled = True txtSurname.Enabled = True txtUsername.Enabled = True txtPassword.Enabled = True End Sub Do I just add that before the .EndCurrentEdit? dsSystemUsers(dsSystemUsers.Passwords.RowCount -1)(?????) = ????? - What do I need to add in the ????? bits? Many Thanks Again, and again sorry for been a pest Cheers Show quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OMvmp3p5FHA.1140@tk2msftngp13.phx.gbl... > Si, > > No see as I showed you. > > You have > Datagrid dsSystemUsers.Passwords > Normal Controls: dsSystemUsers > > So in my opinion they have to be all > Datagrid dsSystemUsers.Passwords > (The table) > > :-) > > Cor > > "NOT_SO_CLEVER" <t***@test.com> schreef in bericht > news:uVUqvrp5FHA.1140@tk2msftngp13.phx.gbl... >> Hi Cor, >> >> Thanks for you reply. Sorry im lost again. Both my Datasource`s are >> dsSystemUsers.Passwords.All I have on my App is 1 DataSet. Could you >> explain a bit more? >> >> Im very sorry about been sooooooo Stupid Cor, but im a newbie and really >> finding it hard to understand some of these things. I have some books on >> the way tho:) >> >> Many Thanks >> Si >> >> >> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >> news:Oninhap5FHA.2956@TK2MSFTNGP12.phx.gbl... >>> Probably because your datagrid has another datasource than that you use >>> in the binding of the textboxes. >>> >>> dsSystemUsers.Passwords >>> >>> I hope this helps, >>> >>> Cor >>> >>>> 'Set Datagrid Data Source >>>> dgdSystemUsers.DataSource = dsSystemUsers.Passwords >>>> 'Set Databining >>>> txtFirstname.DataBindings.Add("Text", dsSystemUsers, >>>> "Passwords.User_First") >>> >>> Cor >>> >>> >> >> > > Si,
Greath it works now, Can you make a new post for this, now this becomes a kind of endless help, this is another problem you know? Cor Show quote "NOT_SO_CLEVER" <t***@test.com> schreef in bericht news:ezDvv2t5FHA.4012@TK2MSFTNGP14.phx.gbl... > Excellent, Now its working, good im so daft:). Cheers for that Cor > > Tell me if im been in pain now, but its just my insert code now thats not > working:( > > You said "It adds always forever at the end of the datasource. Therefore > you know that > you can add the key add > thedatasource(thedatasource.Rowcount - 1)(KeyField) = theTnewKey" > > So if my Insert code is: > > Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles btnAdd.Click > cmSystemUsers.EndCurrentEdit() > cmSystemUsers.AddNew() > Me.dsSystemUsers_PositionChanged() > txtFirstname.Enabled = True > txtSurname.Enabled = True > txtUsername.Enabled = True > txtPassword.Enabled = True > End Sub > > Do I just add that before the .EndCurrentEdit? > > dsSystemUsers(dsSystemUsers.Passwords.RowCount -1)(?????) = ????? - > What do I need to add in the ????? bits? > > Many Thanks Again, and again sorry for been a pest > > Cheers > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:OMvmp3p5FHA.1140@tk2msftngp13.phx.gbl... >> Si, >> >> No see as I showed you. >> >> You have >> Datagrid dsSystemUsers.Passwords >> Normal Controls: dsSystemUsers >> >> So in my opinion they have to be all >> Datagrid dsSystemUsers.Passwords >> (The table) >> >> :-) >> >> Cor >> >> "NOT_SO_CLEVER" <t***@test.com> schreef in bericht >> news:uVUqvrp5FHA.1140@tk2msftngp13.phx.gbl... >>> Hi Cor, >>> >>> Thanks for you reply. Sorry im lost again. Both my Datasource`s are >>> dsSystemUsers.Passwords.All I have on my App is 1 DataSet. Could you >>> explain a bit more? >>> >>> Im very sorry about been sooooooo Stupid Cor, but im a newbie and really >>> finding it hard to understand some of these things. I have some books on >>> the way tho:) >>> >>> Many Thanks >>> Si >>> >>> >>> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >>> news:Oninhap5FHA.2956@TK2MSFTNGP12.phx.gbl... >>>> Probably because your datagrid has another datasource than that you use >>>> in the binding of the textboxes. >>>> >>>> dsSystemUsers.Passwords >>>> >>>> I hope this helps, >>>> >>>> Cor >>>> >>>>> 'Set Datagrid Data Source >>>>> dgdSystemUsers.DataSource = dsSystemUsers.Passwords >>>>> 'Set Databining >>>>> txtFirstname.DataBindings.Add("Text", dsSystemUsers, >>>>> "Passwords.User_First") >>>> >>>> Cor >>>> >>>> >>> >>> >> >> > > |
|||||||||||||||||||||||