diff --git a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs index 0313cf28..e181526c 100644 --- a/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs +++ b/PROMS/ReferencedObjects/LibSource/ctlXMLEditLib/ctlXMLEdit.cs @@ -276,8 +276,10 @@ namespace ctlXMLEditLib bool imagechild; //whether this field is a subchild of an image string imagename; //if subchild of image, name of image parent (for save) string imagedate; //if this was filename, save the date/time stamp + string name; //name of element + string parenthtid; //name of parent element in hashtable for PC items public TextBoxAttrTag(bool reqd, string ptn, RadioButton rd, bool img, - string imgname, string imgdate) + string imgname, string imgdate, string elemname) { this.req_msg = null; this.required = reqd; @@ -286,6 +288,12 @@ namespace ctlXMLEditLib this.imagechild = img; this.imagename = imgname; this.imagedate = imgdate; + this.name = elemname; + + if (name.Contains("_PCCHILD")) + this.parenthtid = name.Substring(0, name.IndexOf("_PCCHILD")); + else + this.parenthtid = null; } public void SetPattern(string pattern) {this.pattern = pattern;} public void SetRequired(bool req) {this.required = req;} @@ -298,6 +306,10 @@ namespace ctlXMLEditLib public string GetImageName { get {return imagename;}} public string GetImageDate { get {return imagedate;}} public void SetImageDate(string imgdate) {this.imagedate = imgdate;} + public string GetName { get { return name; } } + public void SetName(string elemname) { this.name = elemname; } + public string GetParentHTId { get { return parenthtid; } } + public void SetParentHTId(string id) { this.parenthtid = id; } } public ctlXMLEdit(VlnXmlElement myelem, XmlSchema myschema, ArrayList reqfields, ArrayList fldsWithApplic, string [] pckids) @@ -928,7 +940,7 @@ namespace ctlXMLEditLib // initialization. if (mytextbox.Tag == null) { - TextBoxAttrTag tag = new TextBoxAttrTag(false, pattern, radio, img, (img?imgname:null), null); + TextBoxAttrTag tag = new TextBoxAttrTag(false, pattern, radio, img, (img?imgname:null), null, mytextbox.Name); mytextbox.Tag = (object) tag; } return getannot; @@ -1136,6 +1148,7 @@ namespace ctlXMLEditLib mytextbox = new TextBox(); mytextbox.Location = new Point(screenx+indent, screeny); string tFieldName = (pcChildIdx == 0) ? CvtUserFldToFld(element.Name) : CvtUserFldToFld(pcChildFldName); + mytextbox.Name = tFieldName; myHT.Add(tFieldName, mytextbox); tabindx++; Controls.Add(mytextbox); @@ -1201,9 +1214,21 @@ namespace ctlXMLEditLib string dfTxt = ""; try { - ctlXMLEdit tmp = (ctlXMLEdit)tb?.Parent; - if (!string.IsNullOrEmpty(tmp?.ActiveControl.Text)) - dfTxt = tmp.ActiveControl.Text; + string parentid = ((TextBoxAttrTag)tb.Tag).GetParentHTId; + if (!string.IsNullOrEmpty(parentid)) + { + object o = myHT[parentid]; + if (o != null) + dfTxt = (o as TextBox).Text; // set to use the parent's value (default) + } + else + { + + string parName = pcGrpBox.Name.Substring(5); + object o = myHT[parName]; + if (o != null) + dfTxt = (o as TextBox).Text; // set to use the parent's value (default) + } } catch {