B2025-028 RO Editor - Parent Child Applicability - Default Values

While working with parent/child applicability with child applicability set for a setpoint group - assign the Setpoint Values and Short Description fields to have Child values.  All child values default to their parent values as expected.  However, if you click in the Parent field for the Short Description, the Child Values for the Short Description fields incorrectly defaulted to the Parent Setpoint Value instead of keeping the parent Short Description.
This commit is contained in:
Matthew Schill 2025-05-15 10:28:47 -04:00
parent 700d9656b2
commit 2970c0d7d4

View File

@ -276,8 +276,10 @@ namespace ctlXMLEditLib
bool imagechild; //whether this field is a subchild of an image bool imagechild; //whether this field is a subchild of an image
string imagename; //if subchild of image, name of image parent (for save) string imagename; //if subchild of image, name of image parent (for save)
string imagedate; //if this was filename, save the date/time stamp 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, 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.req_msg = null;
this.required = reqd; this.required = reqd;
@ -286,6 +288,12 @@ namespace ctlXMLEditLib
this.imagechild = img; this.imagechild = img;
this.imagename = imgname; this.imagename = imgname;
this.imagedate = imgdate; 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 SetPattern(string pattern) {this.pattern = pattern;}
public void SetRequired(bool req) {this.required = req;} public void SetRequired(bool req) {this.required = req;}
@ -298,6 +306,10 @@ namespace ctlXMLEditLib
public string GetImageName { get {return imagename;}} public string GetImageName { get {return imagename;}}
public string GetImageDate { get {return imagedate;}} public string GetImageDate { get {return imagedate;}}
public void SetImageDate(string imgdate) {this.imagedate = imgdate;} 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) public ctlXMLEdit(VlnXmlElement myelem, XmlSchema myschema, ArrayList reqfields, ArrayList fldsWithApplic, string [] pckids)
@ -928,7 +940,7 @@ namespace ctlXMLEditLib
// initialization. // initialization.
if (mytextbox.Tag == null) 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; mytextbox.Tag = (object) tag;
} }
return getannot; return getannot;
@ -1136,6 +1148,7 @@ namespace ctlXMLEditLib
mytextbox = new TextBox(); mytextbox = new TextBox();
mytextbox.Location = new Point(screenx+indent, screeny); mytextbox.Location = new Point(screenx+indent, screeny);
string tFieldName = (pcChildIdx == 0) ? CvtUserFldToFld(element.Name) : CvtUserFldToFld(pcChildFldName); string tFieldName = (pcChildIdx == 0) ? CvtUserFldToFld(element.Name) : CvtUserFldToFld(pcChildFldName);
mytextbox.Name = tFieldName;
myHT.Add(tFieldName, mytextbox); myHT.Add(tFieldName, mytextbox);
tabindx++; tabindx++;
Controls.Add(mytextbox); Controls.Add(mytextbox);
@ -1201,9 +1214,21 @@ namespace ctlXMLEditLib
string dfTxt = ""; string dfTxt = "";
try try
{ {
ctlXMLEdit tmp = (ctlXMLEdit)tb?.Parent; string parentid = ((TextBoxAttrTag)tb.Tag).GetParentHTId;
if (!string.IsNullOrEmpty(tmp?.ActiveControl.Text)) if (!string.IsNullOrEmpty(parentid))
dfTxt = tmp.ActiveControl.Text; {
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 catch
{ {