Assign databinding for a Textbox on WinForm, using the Properties Panel???

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Anonymous

Assign databinding for a Textbox on WinForm, using the Properties Panel???

Post by Anonymous »

I see a lot of code examples where a Textbox is used on a WinForm and the data binding to the Text property is always done in code using the DataBindings:Add() method.
pipmohciggakmbpm.png
pipmohciggakmbpm.png (14.51 KiB) Viewed 215 times
I'm wondering if it is possible to set this in the UI of the IDE in the Properties panel when you have a control selected in the Form Designer? (XIDE and VS)? Visual Studio indeed has the DataBinding properties available in Properties tab, but I could not get it to accept Self:SomeCustomFormProperty


In Visual FoxPro IDE, databing (ControlSource property) can be assigned in code also, but *many* VFP developers also use the IDE GUI to set ControlSource from the Form Designer, and I'll bet they will be hunting this feature in X# development experience one day.

See below a screenshot of how the FoxPro UI allows setting the "ControlSource" in a visual (that what VFP calls "data binding" for a Textbox).

Here is what it looks like in FoxPro:
moknihdnggjadnjm.png
moknihdnggjadnjm.png (108.28 KiB) Viewed 215 times
Here is what it looks like in Visual Studio:
2019-03-28_6-33-27.png
2019-03-28_6-33-27.png (96.25 KiB) Viewed 215 times
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Assign databinding for a Textbox on WinForm, using the Properties Panel???

Post by wriedmann »

Hi Matt,

the VO was way always a name based binding.

This works very well both in WPF and WinForms, when using own control classes.

You can find a sample for WinForms here:
https://riedmann.it/download/WinformsDa ... gApp.viaef
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FoxProMatt

Assign databinding for a Textbox on WinForm, using the Properties Panel???

Post by FoxProMatt »

Yes, I have seen that example. However, there will be many cases when importing / translating exiting forms that did not use a naming convention.

Imagine a Container (GroupBox) on a form and inside the container is a Textbox, And imagine the oContainer has an oCustomer object on it. And the databinding for the TextBox is "This.Parent.oCustomer.cName"

Yes, I know it might be a little weird to databind one control to an object on another UI control, even an object on the parent container UI control, but such is the possibility in FoxPro, and believe me, many, many people do that in their apps (guilty me too).

Heck even "Thisform.oPurchaseOrder.oCusomtomer.oShippingDestination.cDestinationName"
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Assign databinding for a Textbox on WinForm, using the Properties Panel???

Post by lumberjack »

Hi Matt,
Not going to explain in detail, but here goes...
mattslay wrote: the container is a Textbox, And imagine the oContainer has an oCustomer object on it. And the databinding for the TextBox is "This.Parent.oCustomer.cName"
I have already studied that part of the VFP repo and know what has to be done:

Code: Select all

DELEGATE VFPContainer(blah blah blah) AS VFPContainerTyp
CLASS VFPForm INHERIT System.Windows.Forms.Form
    PROCTECT oContainer AS VFPContainer
    CONSTRUCTOR()
        SUPER()
        SELF:oContainer := ContainerBase
    RETURN
    PROPERTY Container AS VFPContainer GET SELF:oContainer SET SELF:oContainer := VALUE

    METHOD ContainerBase() AS VFPContainer
    RETURN
END CLASS
This the basics of how it work. Still have not got into the details, but if this is not working, I have already the INTERFACE concept also as a Plan B.

Code: Select all

CLASS VFPFormInt INHERIT Form IMPLEMENT IVFPFormContainer.
I know some will say but how this will work. Sorry let me first get my code done for it after we get the VFPRepo INTO X#, then this will become clear. Difficult to understand how I do it, but its a combination of Data-driven, Lexer, Compiler knowledge that I all throw together now... I will explain as we go along. Miss one of those concepts and it is way over your head.
______________________
Johan Nel
Boshof, South Africa
User avatar
Chris
Posts: 4587
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Assign databinding for a Textbox on WinForm, using the Properties Panel???

Post by Chris »

Matt, most probably the VFP window editor will be a dedicated custom editor (although not 100% certain about it yet) and we will make sure that you can edit such stuff exactly the way you are used to doing it already in the VFP IDE.

Yes, in the (WinForms) form designer in XIDE I have not implemented this, actually nobody has ever requested it, so I did not bother, since for my own needs I never use this method of handling data. In VS I think it should be already working though.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply