| | |
| | | using System.Resources; |
| | | using System.Drawing; |
| | | using Newtonsoft.Json; |
| | | using Gs.DevApp.Models; |
| | | using Gs.DevApp.Entity; |
| | | using System.Windows.Forms; |
| | | using static System.Windows.Forms.Control; |
| | | using DevExpress.XtraEditors; |
| | |
| | | /// <param name="isEdt">是否可编辑</param> |
| | | public static void SetValueByObj(ControlCollection controls, dynamic dynamicObject, Boolean isEdt) |
| | | { |
| | | |
| | | foreach (JProperty property in dynamicObject.Properties()) |
| | | { |
| | | string strName = property.Name; |
| | | string strVal = property.Value.ToString(); |
| | | try |
| | | { |
| | | // // 如果value是一个对象,可以递归遍历 |
| | | // if (property.Value is JObject) |
| | | // { |
| | |
| | | if (cols.Length > 0) |
| | | { |
| | | Control colType = cols[0]; |
| | | //LookUpEdit |
| | | if (colType is LookUpEdit) |
| | | { |
| | | LookUpEdit txt = colType as LookUpEdit; |
| | | if (txt != null) |
| | | { |
| | | txt.EditValue = strVal; |
| | | // txt.Text = strVal; |
| | | } |
| | | txt.Enabled = isEdt; |
| | | continue; |
| | | } |
| | | //下拉 |
| | | if (colType is ComboBoxEdit) |
| | | { |
| | |
| | | txt.Enabled = isEdt; |
| | | continue; |
| | | } |
| | | //单选 |
| | | if (colType is CheckEdit) |
| | | { |
| | | CheckEdit txt = colType as CheckEdit; |
| | | if (txt != null) |
| | | txt.Checked = (strVal.ToString() == "1" ? true : false); |
| | | txt.Enabled = isEdt; |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | MessageBox.Show(strName + ex.Message); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 清空容器里面的控件 |