Commit fc9050fa HZH

修改样例及多线程描述信息

1 个父辈 8e2bb35c
......@@ -12,6 +12,6 @@ namespace HZH_Controls.Controls
public int Width { get; set; }
public System.Windows.Forms.SizeType WidthType { get; set; }
public string DataField { get; set; }
public Func<object, string> Format { get; set; }
}
}
......@@ -209,12 +209,12 @@ namespace HZH_Controls.Controls
get { return m_page; }
set
{
if (!typeof(IPageControl).IsAssignableFrom(value.GetType()) || !value.GetType().IsSubclassOf(typeof(UCPagerControlBase)))
throw new Exception("翻页控件没有继承UCPagerControlBase");
panPage.Visible = value != null;
m_page = value;
if (value != null)
{
if (!typeof(IPageControl).IsAssignableFrom(value.GetType()) || !value.GetType().IsSubclassOf(typeof(UCPagerControlBase)))
throw new Exception("翻页控件没有继承UCPagerControlBase");
panPage.Visible = value != null;
m_page.ShowSourceChanged += page_ShowSourceChanged;
m_page.Dock = DockStyle.Fill;
this.panPage.Controls.Clear();
......
......@@ -73,7 +73,17 @@ namespace HZH_Controls.Controls
{
var pro = DataSource.GetType().GetProperty(com.DataField);
if (pro != null)
cs[0].Text = pro.GetValue(DataSource, null).ToStringExt();
{
var value = pro.GetValue(DataSource, null);
if (com.Format != null)
{
cs[0].Text = com.Format(value);
}
else
{
cs[0].Text = value.ToStringExt();
}
}
}
}
}
......
......@@ -412,7 +412,6 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram1.cd" />
<None Include="Resources\alarm.png" />
</ItemGroup>
<ItemGroup>
......
......@@ -44,9 +44,9 @@
this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(0, 61);
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(679, 416);
this.ucDataGridView1.TabIndex = 3;
//
......@@ -56,7 +56,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(679, 477);
this.Controls.Add(this.ucDataGridView1);
this.FrmTitle = "Temp1测试";
this.FrmTitle = "表格测试";
this.IsFullSize = false;
this.Name = "FrmTemp1Test";
this.Text = "FrmTemp1Test";
......
......@@ -19,28 +19,30 @@ namespace Test
private void FrmTemp1Test_Load(object sender, EventArgs e)
{
List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "ID", HeadText = "编号", Width = 70, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = 50, WidthType = SizeType.Percent });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Age", HeadText = "年龄", Width = 50, WidthType = SizeType.Percent });
this.ucDataGridView1.Columns = lstCulumns;
this.ucDataGridView1.IsShowCheckBox = true;
List<object> lstSource = new List<object>();
for (int i = 0; i < 20; i++)
{
List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "ID", HeadText = "编号", Width = 70, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = 50, WidthType = SizeType.Percent });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Age", HeadText = "年龄", Width = 50, WidthType = SizeType.Percent });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Birthday", HeadText = "生日", Width = 50, WidthType = SizeType.Percent, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd"); } });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Sex", HeadText = "性别", Width = 50, WidthType = SizeType.Percent, Format = (a) => { return ((int)a) == 0 ? "女" : "男"; } });
this.ucDataGridView1.Columns = lstCulumns;
this.ucDataGridView1.IsShowCheckBox = true;
List<object> lstSource = new List<object>();
for (int i = 0; i < 20; i++)
{
TestModel model = new TestModel()
{
ID = i.ToString(),
Age = 3 * i,
Name = "姓名——" + i
Name = "姓名——" + i,
Birthday = DateTime.Now.AddYears(-10),
Sex = i % 2
};
lstSource.Add(model);
}
}
UCPagerControl page = new UCPagerControl();
page.DataSource = lstSource;
this.ucDataGridView1.Page = page;
this.ucDataGridView1.First();
this.ucDataGridView1.DataSource = lstSource;
this.ucDataGridView1.First();
}
}
......@@ -49,5 +51,7 @@ namespace Test
public string ID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public DateTime Birthday { get; set; }
public int Sex { get; set; }
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!