Paul,
All agreed there. The point I was trying to make was that the Databinding is
difficult to implement as a "two way" binding  unless you know about adding
a PropertyChangedEventHandler to your class. 

I do it slightly different in that I can track for variousl update "Modes"by
adding an Enum to the class:

// Enum for changed states
public enum EntityStateEnum
{
  Unchanged,
  Added,
  Deleted,
  Modified,
}

// Custom Method to handle Entity State
public EntityStateEnum EntityState
{
  get { return _EntityState; }
  private set { _EntityState = value; }
}

...and then a Datastate Changed Method handler:

//
private void DataStateChange(EntityStateEnum dataState, string propertyName)
{
  // Raise the event
  if (PropertyChanged != null && propertyName != null)
  {
    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  }
  
  // If the state is deleted, mark it as deleted
  if (dataState == EntityStateEnum.Deleted)
  {
    this.EntityState = dataState;
  }

  if (this.EntityState == EntityStateEnum.Unchanged)
  {
    this.EntityState = dataState;
  }
}

Then, in the property get/set:

// Example get/set for object property
private int _nBalance ;
public int nBalance
{
  get { return _nBalance; }
  set   { if( value != nBalance)
        {
          this.DataStateChange(EntityStateEnum.Modified, "nBalance");
          _nBalance = value;
        }
      }
}

Basically though, the same methodology as yourself but with a little more
control.

All in all though, it isn't easy to find these things out when you are
starting out as we just take 2 way data binding as a standard feature in
VFP.

Dave Crozier


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Paul Hill
Sent: 06 October 2008 13:34
To: ProFox Email List
Subject: Re: [NF] VB.Net Questions

On Mon, Oct 6, 2008 at 9:43 AM, Dave Crozier <[EMAIL PROTECTED]> wrote:
> John,
> I concur with the other group comments but would suggest that you
seriously
> look at C# as opposed to VB.Net.

Agreed.  Although I'm still starting out with .NET there seems to be
much more information out there on C# than VB.

> The execution speed is much superior and the OOP things you can do bear
more of a similarity to VFP than VB.

Is the speed really different?  I thought C# and VB were the same
language with different 'layouts'.

> My comments, so far, apart from the changed language syntax, having
written
> some 20-30 C# applications are as follows:
>
> Pro:
> 1. My main gripe - Data Binding of Objects to UI classes are a pain in
> VS2005 unless you bind to a Datasource (VFP Cursor equivalent). You can
bind
> an object property quite easily to a textbox for example but the
> relationship is one way only i.e changing the Control u[dates the object
> property but NOT Vice versa without a lot of messing about. This has been
> improved in VS2008 but is still nowhere as easy as in VFP. There is no
> concept of "Controlsource" as we VFPer's know it.

As I said, I'm still toying with .NET but I managed to bind objects to
gui elements fairly easily by implementing the INotifyPropertyChanged
interface.

My object has get/set methods like this:

      private string _name;
      public string name
      {
         get { return this._name; }
         set { this._name = value; NotifyPropertyChanged("name"); }
      }

A change to the object automatically updates the textbox etc.

> 5. I still can't get used to using a "==" as opposed to a "=" in an if
> statement and having to use != as opposed to <>. These still screw me up
all
> the time. One other construct that is a pain is the VFP "Do Case"
equivalent
> i.e Switch. You can forget about putting in case <....> statements that
> refer to any variable/function as you have to reference the variable(s)
> specified in the initial "Switch" statement.

I come from a C background so that's fine by me :-)

Currently I'm struggling with the fact that ASP.NET only supports
'connectionless' data.  The idea is that you connect to the database,
get your data and disconnect.  The problem

-- 
Paul


[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to