Sample Form Bound to .DBF fields

This forum is meant for questions about the Visual FoxPro Language support in X#.

Jeff Stone
Posts: 37
Joined: Fri Jun 07, 2019 4:16 pm

Sample Form Bound to .DBF fields

Post by Jeff Stone »

I'm continuing my testing and getting acquainted with X# and am now trying to better understand how forms/form syntax bind to .DBF variables. Since my initial testing is all using XIDE, can someone point me to sample code or a sample XIDE application that shows this?

TIA,

Jeff
User avatar
wriedmann
Posts: 3752
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Sample Form Bound to .DBF fields

Post by wriedmann »

Hi Jeff,
are you talking about Windows Forms Databinding?
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FoxProMatt

Sample Form Bound to .DBF fields

Post by FoxProMatt »

are you talking about Windows Forms Databinding?
@Wolfagng -

I bet because he is a FoxPro guy, he's trying to do that thing we all do... Trying to see how similar the new system it to the old one we know so well.

In FoxPro, if you have a UI control on a Form, there is a single property on the called ControlSource, and you'd set that to a string value that references one of two possible sources of data:
.
  • Cursor.FieldName reference
  • or
    [LI]ObjectRef.PropertyName
.
2020-08-21_8-27-12.png
2020-08-21_8-27-12.png (146.62 KiB) Viewed 679 times
User avatar
Chris
Posts: 4855
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Sample Form Bound to .DBF fields

Post by Chris »

Matt (and Jeff),

Understood, but there are several different things you can do in .Net and X#:

1. People with existing VO apps (or who want to keep developing the same way in X#) can use the VO compatible window editor, which exactly like in VO, uses a similar mechanism to what you described in FoxPro, in order to do data binding

2. Windows Forms has it's own different data binding system

3. WPF uses a yet another different system for data binding, which is by far the most sophisticated AFAIK

4. Of course you can implement your own data binding system, which works exactly as you want it to. Myself (and a lot of other people) in VO I had never used the built in system but instead wrote something custom that works between the user and the GUI, for maximum flexibility.

5. In the future, there will be a form designer for VFP apps and developers, which will probably work in an identical way to that of VFP, exactly as you are familiar with it. Similar solution to what we did with the VO dialect, where the window editor is identical to that of VO.

So there's not really one specific way of how data binding works in X# and/or .Net. It's how you want it to work, depending first of all on the GUI solution you plan to use.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3752
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Sample Form Bound to .DBF fields

Post by wriedmann »

Hi Matt,
in VO we have something that is called "name-based binding". That means that you have a datasource (mostly a DBServer object or a SQL Dataset), and when you bind that to a datawindow, the controls will be bound to a field of the same name in the datasource. For example, if you have a field called "foxpro" in your window, and a field of the same name in the datasource, the binding procedure will establish a bidirectional binding. Changing the field in the window will change it in the datasource and viceversa.

Windows Forms (and WPF) are not database centric environments, so they know nothing about this. But they offer another (much more powerful, specially in the case of WPF) binding mechanism, and with a bit of generic code and a Form subclass it is possible to establish the same behavior as in VO.

I have some samples for this, both in WPF and in Windows Forms, but non of them is complete to show what can be accomplished.

Of course you can bind any value to any field als in Windows Forms and WPF, but it is a manual work.

Personally I have found it rather confusing to have a control named "Edit1" bound to a field value "artcode", and was really happy that the VO databinding has constrained us to use meaningful names also for the controls. (I had to deal with manual bindings in a Delphi project I had to maintain, but fortunately I was able to pass this project to an employee that had Delphi knowledge from a former work).

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FoxProMatt

Sample Form Bound to .DBF fields

Post by FoxProMatt »

5. In the future, there will be a form designer for VFP apps and developers, which will probably work in an identical way to that of VFP, exactly as you are familiar with it. Similar solution to what we did with the VO dialect, where the window editor is identical to that of VO.
Chris - ok, this i new news, it seems... Last I understood, WinForms was going to be the target for migrated VFP apps. A dedicated VFP form designer, is, well... I'm snot sure what even to say. Welcomed, I believe, especially it is a LOT like the VFP form designer. But, man, it seems like a TON of work. And underneath of it, what is really there?
User avatar
Chris
Posts: 4855
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Sample Form Bound to .DBF fields

Post by Chris »

FoxProMatt wrote:
5. In the future, there will be a form designer for VFP apps and developers, which will probably work in an identical way to that of VFP, exactly as you are familiar with it. Similar solution to what we did with the VO dialect, where the window editor is identical to that of VO.
Chris - ok, this i new news, it seems... Last I understood, WinForms was going to be the target for migrated VFP apps. A dedicated VFP form designer, is, well... I'm snot sure what even to say. Welcomed, I believe, especially it is a LOT like the VFP form designer. But, man, it seems like a TON of work. And underneath of it, what is really there?
Is it really news? Haven't we been discussing this for quite some time publicly about providing a way to edit forms in a VFP-similar way? There was even a thread in Foxite asking about people's opinion on this..

OK, a directly compatible to VFP form editor is only on of two most likely solutions, the other being adjusting the standard WinForms editor (with control subclassing etc) to bring it closer to that of VFP. Both solutions have their pros and cons, still not sure which path we will follow at the end, my personal view is it is more likely we will need to do the completely custom one. Doing both is another option of course...
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Jeff Stone
Posts: 37
Joined: Fri Jun 07, 2019 4:16 pm

Sample Form Bound to .DBF fields

Post by Jeff Stone »

Matt was kind of correct in that I'm looking at X# from a VFP user's perspective. I was just trying to understand how quickly using XIDE I could display .dbf fields in a form. I didn't see any mention of this in the XIDE Help pages nor did I find a video demonstrating this either; hence my post. FWIW, I have also converted a number of our VFP forms in Harbour MiniGui which can be done with just a moderate amount of effort.

To attract and keep VFP users, I think it's helpful to start them off with an interface experience that is somewhat similar to what they are used to. My initial impression is XIDE is far closer than VS. While I haven't played with XSI.exe yet, I was thinking that if it were embedded in XIDE, it might function like the VFP command window. This experience should be coupled with a simple tutorial of XIDE that shows the basic elements of using X#. (Eric Selje's article at https://saltydogllc.com/wp-content/uplo ... -Sharp.pdf might be a good starting point for VFPers even if the article is already slightly out of date.)

Anyway, back to my original question, does XIDE form generation allow me to quickly display dbf field data in a form? If so, how?

TIA,

Jeff
User avatar
wriedmann
Posts: 3752
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Sample Form Bound to .DBF fields

Post by wriedmann »

Hi Jeff,
if no one is able to have an example, I will try to do one. But first I have to play with the VFP view of data.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4483
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Sample Form Bound to .DBF fields

Post by robert »

Jeff,
I am preparing a session about Data Binding in .Net for Virtual Fox Fest.
Unfortunately I do not have the X# VFP part ready yet, so I cannot upload the example.
But that should be ready in a week or two.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply