Author
|
Message
|
Gary Smith
|
|
Group: Forum Members
Last Active: 14 Years Ago
Posts: 39,
Visits: 1
|
Is it possible to use a dataset as the bind for the datanavigator? I have: (This is for a microsoft access query) Dim dsFindings As New DataSet Dim daFindings As OleDb.OleDbDataAdaptersql = "select tbl_findings.id, tbl_findings.location, tbl_findings.RAC, tbl_findings.checklist_number, tbl_findings.checklist, tbl_findings.corrective_actions,tbl_findings.reference,tbl_findings.notes, tbl_findings.discrepnum from tbl_findings where opfac='" & curOpfac & "' and visitdate=#" & curVisitDate & "# and visittype='" & curVisitType & "' order by tbl_findings.discrepnum" ' run the sql statement against the connection stringdaFindings = New OleDb.OleDbDataAdapter(sql, con)' fill the dataset with datadaFindings.Fill(dsFindings, "tbl_Findings")
If this is possible, how would I bind it? I tried: NDataNavigator1.DataNavigatorElement.DataSource = dsFindingsBut that did nothing.... Thanks!
|
|
|
Angel Chorbadzhiev
|
|
Group: Forum Members
Last Active: Last Month
Posts: 139,
Visits: 184
|
Hi Gary, You should specify the table of your data set as a data source of your NDataNavigator: NDataNavigator1.DataNavigatorElement.DataSource = dsFindings.Tables(0) Regards, Angel.
|
|
|
Gary Smith
|
|
Group: Forum Members
Last Active: 14 Years Ago
Posts: 39,
Visits: 1
|
Thanks Angel, that works perfectly. Now that I have the navigator running, and displaying the correct number of records etc... How do I assign a function/sub to the next, next page, last record buttons so I can advance the records? I already have the functions next,prev etc designed and working, just need to know how I access the controls button pressed and assign it to the right function... Thanks
|
|
|
Angel Chorbadzhiev
|
|
Group: Forum Members
Last Active: Last Month
Posts: 139,
Visits: 184
|
Hi Gary, You need to attach to ButtonClick event and in the event handler you can use DataNavigatorElement.Current property to determine which is the selected item from your data source. Regards, Angel.
|
|
|
Gary Smith
|
|
Group: Forum Members
Last Active: 14 Years Ago
Posts: 39,
Visits: 1
|
Angel, sorry for being so ignorant - however, I dont see a button event for the nDataNavigator, when attempting to get a value or button pressed I'm trying: Private Sub NDataNavigator1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NDataNavigator1.Click and cant figure it out.... (Which button pressed, next, next page, last) however using the following in the OnClick event I can use NDataNavigator1.DataNavigatorElement.RecordIndex I can get the current index... but I need to know which button was pressed and I just dont see the Button.Click event....Can you provide me with an example if the "next" button is pressed? I also found where the buttons contain an index value of First=3, Last=8, Next=6 etc, but still can not find a way of obtaining that value... Sorry... I'm pretty good if shown an example, but cant find one in the docs... Thanks again!
|
|
|
Angel Chorbadzhiev
|
|
Group: Forum Members
Last Active: Last Month
Posts: 139,
Visits: 184
|
Hi Garry, You can find example that demonstrates how to use NDataNavigator in the examples application that is provided with the controls. Here is a code snipped that shows how you have to attach to ButtonClick event: Private Sub NDataNavigator1_ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NDataNavigator1.DataNavigatorElement.ButtonClickEnd SubTo get the id of the pressed button you can do the following: Dim buttonId As Integer = TryCast(sender, NRepeatButtonElement).PartStateInfo.PartIdI hope now is more clear. Regards, Angel.
|
|
|
Gary Smith
|
|
Group: Forum Members
Last Active: 14 Years Ago
Posts: 39,
Visits: 1
|
Thanks for the example Angel. From this I can see how it works to obtain the id of the button pressed, however for clarification - as for samples, I could find none that describe how to use the NDataNavigator control, The example provided basically shows how to assign a datasource. There is also no documentation on this control in the online, or supplied docs... oversight? Also (more importantly) I am seeing this error now since adding the NDataNavigator_ButtonClick event.... Warning 1 Unable to cast object of type 'Nevron.UI.NDataNavigatorElement' to type 'System.ComponentModel.IComponent'. 0 0
Suggestions?
|
|
|
Gary Smith
|
|
Group: Forum Members
Last Active: 14 Years Ago
Posts: 39,
Visits: 1
|
Angel, Same topic NDataNavigator (still getting that warning, have tried saving and rebuilding without luck). I have the control on a tabbed page, and when I navigate away from that page, I add a record to the database, when I come back to that page, and conduct the sql query again, the text in NDataNavigator does not update to the correct number of records contained in the dataset, how do you refresh that? The data source is cleared before performing the sql transaction, and the correct number of records is contained in the dataset however the record count on the control does not update. I tried the .refresh without luck. Also, I need to change the tooltip text of the Next Page and Prev Page buttons, How can I perform that action? Thanks -
|
|
|
Angel Chorbadzhiev
|
|
Group: Forum Members
Last Active: Last Month
Posts: 139,
Visits: 184
|
Hi Gary, I am not very familiar with vb, but if you change the way you attach to the ButtonClick event as the following you should not get this warning: AddHandler NDataNavigator1.DataNavigatorElement.ButtonClick, AddressOf NDataNavigator1_ButtonClickPrivate Sub NDataNavigator1_ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs)End Sub Regarding the updating of the data source you need to call UpdateDataSource method of the DataNavigatorElement: NDataNavigator1.DataNavigatorElement.UpdateDataSource() Regarding changing the tooltip texts it si little more complicated. Here is an example again: Dim buttons As NNodeList = NDataNavigator1.DataNavigatorElement.Children(Nothing)Dim count As Integer = buttons.CountFor i As Integer = 0 To count - 1 If TypeOf buttons(i) Is NRepeatButtonElement Then Dim button As NRepeatButtonElement = TryCast(buttons(i), NRepeatButtonElement) If button.TooltipText = "Previous Page" Then button.TooltipText = "My Previous Page" End If If button.TooltipText = "Next Page" Then button.TooltipText = "My Next Page" End If End IfNext I hope this helps. Please, let me know if you have any questions. Regards, Angel.
|
|
|
Gary Smith
|
|
Group: Forum Members
Last Active: 14 Years Ago
Posts: 39,
Visits: 1
|
Angel, once again you've headed me in the right direction ! All examples worked fine. Adding the Event Handler was indeed the problem. No problems with the refresh or updating the tooltips. Thanks again! Gary
|
|
|