cjard
Well-known member
- Joined
- Apr 25, 2006
- Messages
- 7,081
- Programming Experience
- 10+
Hi All
I'm seeking opinion on the ease of doing the following:
In my particular app, not all elements visible on screen ought to be editable at a particular time
For example, once created an address cannot be changed, a new address must be created
Presently, when viewing an existing address it looks to be editable but the database ignores any attempts to change it (the textboxes are editable, the edits are sent to the datatable, but the UPDATE sql that would persist the changes is deliberately absent to prevent address details being updated)
I've been pondering various solutions for a while, and I think the best thing would be to get the textboxes themselves to realise when the address on show is an already existing one or a new one.
This is quite easy to achieve by examining the RowState of the row unto which the boxes are bound. To whit, I'd like to add 4 properties, visible in the form designer property grid, for the status a textbox should adopt(Editable, ReadOnly, Disabled) when the underlying row state is Added, Modified, Unchanged.
Does anyone have any comments on this in terms of how I'd do it - subclass a textbox, but what events to listen for to determine when the databound item the textbox is looking at, has changed?
Or comments in terms of a better proposal?
Thanks in advance
I'm seeking opinion on the ease of doing the following:
In my particular app, not all elements visible on screen ought to be editable at a particular time
For example, once created an address cannot be changed, a new address must be created
Presently, when viewing an existing address it looks to be editable but the database ignores any attempts to change it (the textboxes are editable, the edits are sent to the datatable, but the UPDATE sql that would persist the changes is deliberately absent to prevent address details being updated)
I've been pondering various solutions for a while, and I think the best thing would be to get the textboxes themselves to realise when the address on show is an already existing one or a new one.
This is quite easy to achieve by examining the RowState of the row unto which the boxes are bound. To whit, I'd like to add 4 properties, visible in the form designer property grid, for the status a textbox should adopt(Editable, ReadOnly, Disabled) when the underlying row state is Added, Modified, Unchanged.
Does anyone have any comments on this in terms of how I'd do it - subclass a textbox, but what events to listen for to determine when the databound item the textbox is looking at, has changed?
Or comments in terms of a better proposal?
Thanks in advance