Just looked and this post should be in a different forum, sorry.
I want to know the best way to handle my situation with dev force, new to databinding and a green horn to object orientated programming.
Preamble before the question:
I have a table called SysCodes that has columns:
SysCodeID
SysCodeParentID
SysCodeDescription
And the data in this table looks like the following
1, 0, ApplyTo
2, 0, DataType
3, 0, Color
4,1,In Place
5,1,In Process
6,2,System Code List
7,2,Boolean
8,2,Number
9,3,Red
10,3, Yellow
I created 2 classes in the object mapper called SC_ApplyTo, SC_DataType but the third one Color is not an enumeration because the user is allowed to add as many colors as they want into the System code table. They are not allowed to edit or add to datatypes or apply to.
I unchecked the visible box for the ones I don't want in that particular enumeration.
When creating the classes I put in a where clause to filter the data. for example SysCodeParentID=1 for the SC_ApplyTo Class.
Question Setup:
On a form there is a datagrid with 3 columns bound to a table called Results:
DataType, SyscodeType, Value
If the user chooses a data type of Value then Syscodetype column is disabled and the user simply types in a number.
If the user chooses boolean then the value field becomes a combobox where they can choose True or False which is translated back to the DB as 0 or 1.
If the user chooses a data type of System Code List then the syscodetype column is enabled and the user is able to choose from a list of SyscodeTypes (Applyto, Datatype or Color). When they choose from that list the value column then becomes a combobox with a list of colors in it that the user can choose. (assuming they picked the syscodetype of color)
Ok, here's the question:
I'm new to this whole databinding and DevForce thing and even object oriented programming and I want to know the best way to do this.
One way is to create a new property called ShownValue in the Result table class.
public String ShownValue
{
get {
return the text or number converted to string depending if the Datatype is syscodelist,boolean or value.
}
set {
if the value is lets say Red then set the value field in the table to the related syscodeid that matches to Red.
}
}
I don't like this way because I have to cast the number to a string and if the value they entered in was 1.2345 it's a string.
I've got this working perfectly in the current application because we are not using databinding and I use the events of the grid to change the cells to comboboxes and fill them with the correct values. We are using infragistics controls and I use the RowInitialize and the cell changed events to handle all the logic.
What's the best way todo this with databinding and devforce? There are 2 places that need to work together, the Results object and the grid.
Edited by DataMan - 10-Aug-2007 at 1:34pm