In Delphi 7 navigating a dataset was a snap. You could use a TdbNavigator, or simply call the methods Next or Prior.
In a Winforms application it is not obviuos how to do this. A way to do this is using a CurrencyManager.
A currencymangager manages a list of bindings. A binding binds a value of a property to an object, just as in binding data to a grid.
(Live used to be simple in Delphi 7 :-) )
To navigate a dataset the code looks something like this:
procedure frmMain.MoveRecord(Step : Integer);
var
cm : CurrencyManager;
begin
cm := BindingContext[dsProjects, 'Project'] As CurrencyManager; cm.Position := cm.Position + Step;
Label1.Text := dsProjects.Tables[0].Rows[cm.Position].Item['pr_number'].ToString;
end;
This codes moves the dataset Step records and shows the value of the field pr_number of the current row in a label.
Remark that when you sort your grid, you should also sort your dataset, otherwise they will not be synchronized.
Programming blogs containing .NET, C#, LINQ, Objective-C and Delphi experiences
Subscribe to:
Post Comments (Atom)
Use an image as your UIBarButtonItem
Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...
-
In ASP.NET it is easy to set the prefered authentication method in the web.config file. For external websites this is set mostly to Forms ...
-
Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...
-
How to get, for example, all the hyperlinks from a webpage, which is loaded in your iPhone app using the UIWebView control? (Xcode's web...
No comments:
Post a Comment