ab56a9bcf7
SVN-Revision: r240
197 lines
6.7 KiB
C#
197 lines
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.Control.Model;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
public partial class LabelRadioButtonGroupEdit : BaseUserControl
|
|
{
|
|
|
|
public DataTable mTable = new DataTable();
|
|
|
|
public LabelRadioButtonGroupEdit()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
/// <summary>
|
|
/// 文本控件
|
|
/// </summary>
|
|
public RadioGroup TextEdit { get { return radioGroup1; } }
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置控件显示文本</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="text">显示Lebel文本</param>
|
|
public override string LabelText
|
|
{
|
|
get
|
|
{
|
|
return this.lblText.Text;
|
|
}
|
|
set
|
|
{
|
|
this.lblText.Text = value;
|
|
if (FontSize > 0)
|
|
{
|
|
this.plLeft.Dock = DockStyle.Left;
|
|
this.plLeft.AutoSize = false;
|
|
this.lblText.AutoSize = false;
|
|
this.lblText.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
this.lblText.Location = new System.Drawing.Point(0, 0);
|
|
this.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
this.plLeft.Width = value.Length * GetCharWidth();
|
|
|
|
GetCharWidthMultilingual(this.lblText, this.lblText.Text, this.plLeft);
|
|
}
|
|
else
|
|
{
|
|
this.plLeft.Width = this.lblText.Width + PaddingLeft;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 字体大小
|
|
/// </summary>
|
|
/// <value>The size of the control.</value>
|
|
public override float FontSize
|
|
{
|
|
get
|
|
{
|
|
return base.FontSize;
|
|
}
|
|
set
|
|
{
|
|
base.FontSize = value;
|
|
if (value > 0)
|
|
{
|
|
this.lblText.Font = new Font(this.lblText.Font.FontFamily, value);
|
|
this.TextEdit.Font = new Font(this.TextEdit.Font.FontFamily, value);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置控件值</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
public override string EditText
|
|
{
|
|
get
|
|
{
|
|
return this.radioGroup1.SelectedIndex == -1
|
|
? ""
|
|
: this.Model.FieldType == ControlType.LabRadioGroupValue
|
|
? this.radioGroup1.Properties.Items[this.radioGroup1.SelectedIndex].Value + ""
|
|
: this.radioGroup1.Properties.Items[this.radioGroup1.SelectedIndex].Description + "";
|
|
}
|
|
set
|
|
{
|
|
if (this.Model != null)
|
|
{
|
|
string key = this.Model.FieldType == ControlType.LabRadioGroupValue ? this.Model.ValueMember : this.Model.TextMember;
|
|
DataRow rowItem = mTable.Rows.Cast<DataRow>().FirstOrDefault(x => x[key] + "" == value);
|
|
|
|
for (int i = 0; i < mTable.Rows.Count; i++)
|
|
{
|
|
DataRow item = mTable.Rows[i];
|
|
if ((item[key] + "").Equals(value))
|
|
{
|
|
this.radioGroup1.SelectedIndex = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 只读文本颜色
|
|
/// </summary>
|
|
/// <value>The color of the read only label.</value>
|
|
public override bool ReadOnly
|
|
{
|
|
get
|
|
{
|
|
return base.ReadOnly;
|
|
}
|
|
set
|
|
{
|
|
base.ReadOnly = value;
|
|
this.radioGroup1.Properties.ReadOnly = value;
|
|
this.lblText.ForeColor = value ? base.ReadOnlyLabelForceColor : Required ? base.RequiredLabelForceColor : base.DefaultLabelForceColor;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 必填文本颜色
|
|
/// </summary>
|
|
/// <value>The color of the required label.</value>
|
|
public override bool Required
|
|
{
|
|
get
|
|
{
|
|
return base.Required;
|
|
}
|
|
set
|
|
{
|
|
base.Required = value;
|
|
if (value)
|
|
{
|
|
this.lblText.ForeColor = base.RequiredLabelForceColor;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-01-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="table">The table.</param>
|
|
public void SetDataSource(ControlModel model, DataTable table)
|
|
{
|
|
if (string.IsNullOrEmpty(model.ValueMember) || string.IsNullOrEmpty(model.TextMember) || string.IsNullOrEmpty(model.SourceSql))
|
|
{
|
|
MessageUtil.Show("配置不对哦\r\n这个字段" + model.LabelText + "[Value字段、Text字段、SQL]\r\n这3个列都要配置.");
|
|
this.radioGroup1.Properties.Items.Clear();
|
|
}
|
|
else
|
|
{
|
|
this.mTable = table;
|
|
this.radioGroup1.Properties.Items.Clear();
|
|
this.radioGroup1.Properties.Columns = table.Rows.Count;
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
string itemValue = model.FieldType == ControlType.LabRadioGroupValue ? item[model.ValueMember] + "" : item[model.TextMember] + "";
|
|
string itemText = item[model.TextMember] + "";
|
|
|
|
DevExpress.XtraEditors.Controls.RadioGroupItem radioItem = new DevExpress.XtraEditors.Controls.RadioGroupItem(itemValue, itemText);
|
|
this.radioGroup1.Properties.Items.Add(radioItem);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|