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

Merged
jjenko merged 1 commits from B2025-028 into Development 2025-05-15 10:41:41 -04:00

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
{ {