From a50aeb0a5e51a83f950811b0b3cfa321a9f7b88e Mon Sep 17 00:00:00 2001 From: Joaquin Date: Wed, 16 Oct 2024 12:49:24 +0300 Subject: [PATCH] Adding RadioButton serialisor and deserialisor. --- FormSerialisor.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/FormSerialisor.cs b/FormSerialisor.cs index 8cbafac..efa0389 100644 --- a/FormSerialisor.cs +++ b/FormSerialisor.cs @@ -79,6 +79,11 @@ private static void AddChildControls(XmlTextWriter xmlSerialisedForm, Control c) { xmlSerialisedForm.WriteElementString("Text", ((DateTimePicker)childCtrl).Text); } + + else if (childCtrl is RadioButton) + { + xmlSerialisedForm.WriteElementString("RadioButton", ((RadioButton)childCtrl).Checked.ToString()); + } // this next line was taken from http://stackoverflow.com/questions/391888/how-to-get-the-real-value-of-the-visible-property // which dicusses the problem of child controls claiming to have Visible=false even when they haven't, based on the parent // having Visible=true @@ -161,6 +166,10 @@ private static void SetControlProperties(Control currentCtrl, XmlNode n) case "System.Windows.Forms.DateTimePicker": ((System.Windows.Forms.DateTimePicker)ctrlToSet).Text = n["Text"].InnerText; break; + + case "System.Windows.Forms.RadioButton": + ((System.Windows.Forms.RadioButton)ctrlToSet).Checked = Convert.ToBoolean(n["RadioButton"].InnerText); + break;; } ctrlToSet.Visible = Convert.ToBoolean(n["Visible"].InnerText); // if n has any children that are controls, deserialise them as well @@ -200,4 +209,4 @@ private static Control GetImmediateChildControl(Control[] ctrl, Control currentC } } -} +} \ No newline at end of file