Skip to content

Commit

Permalink
GridView
Browse files Browse the repository at this point in the history
  • Loading branch information
yscom-git committed May 18, 2024
1 parent b3cb7d0 commit 5aa10c9
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 4 deletions.
93 changes: 91 additions & 2 deletions YMES.FX.Controls/YDataGridView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,52 @@
using System.Collections;
using System.Xml.Linq;
using YMES.FX.Controls.Base;
using System.Runtime.CompilerServices;

namespace YMES.FX.Controls
{
[ToolboxBitmap(typeof(DataGridView))]
public partial class YDataGridView: DataGridView, Base.IYGrid
{
private DataGridViewContentAlignment m_HeaderAlignment = DataGridViewContentAlignment.MiddleCenter;
private GridModeEnum m_GridMode = GridModeEnum.QueryNomal;
private bool m_FixedSort = true;
public enum GridModeEnum
{
QueryNomal
, UserSetting
}
private GridModeEnum m_GridMode = GridModeEnum.QueryNomal;
[Category(Common.CN_CATEGORY_APP)]
public bool FixedSort
{
get { return m_FixedSort; }
set
{
m_FixedSort = value;

foreach (DataGridViewColumn col in this.Columns)
{
if (m_FixedSort)
{
col.SortMode = DataGridViewColumnSortMode.NotSortable;
}
else
{
col.SortMode = DataGridViewColumnSortMode.Automatic;
}
}
}
}
[Category(Common.CN_CATEGORY_APP)]
public DataGridViewContentAlignment HeaderAlignment
{
get { return m_HeaderAlignment; }
set
{
m_HeaderAlignment = value;
AlignHeader();
}
}
[Category(Common.CN_CATEGORY_APP)]
public GridModeEnum GridMode
{
Expand All @@ -31,8 +64,58 @@ public GridModeEnum GridMode
}
public YDataGridView()
{
InitializeComponent();
InitializeComponent();
}
private void AlignHeader()
{
foreach(DataGridViewColumn col in this.Columns)
{
col.HeaderCell.Style.Alignment = HeaderAlignment;
}
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
this.AutoGenerateColumns = false;
foreach (DataGridViewColumn col in this.Columns)
{
if (m_FixedSort)
{
col.SortMode = DataGridViewColumnSortMode.NotSortable;
}
else
{
col.SortMode = DataGridViewColumnSortMode.Automatic;
}
}
if (GridMode == GridModeEnum.QueryNomal)
{

this.MultiSelect = false;
this.RowHeadersVisible = false;
this.ReadOnly = true;
this.MultiSelect = false;
this.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.AllowUserToAddRows = false;
this.AllowUserToOrderColumns = false;
this.AllowUserToResizeColumns = false;
this.AllowUserToResizeRows = false;
this.AllowUserToOrderColumns = false;
this.RowTemplate.Height = 40;
this.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
this.ColumnHeadersHeight = 30;
this.ClipboardCopyMode = DataGridViewClipboardCopyMode.Disable;
this.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
}
}
protected override void OnDataBindingComplete(DataGridViewBindingCompleteEventArgs e)
{
base.OnDataBindingComplete(e);
AlignHeader();
ClearSelection();
}

#region Interface Define

public void ClearValue()
{
Expand Down Expand Up @@ -116,6 +199,10 @@ public void SetValue(object val)
}
public void SetValue(object val, string colName = "Value")
{
if(Columns.Count <=0)
{
AutoGenerateColumns = true;
}
if (val is DataTable)
{
this.DataSource = val;
Expand Down Expand Up @@ -149,5 +236,7 @@ public void SetValue(object val, string colName = "Value")
this.DataSource = dt;
}
}
#endregion

}
}
38 changes: 37 additions & 1 deletion YMES.Logics/MES/TagPrint.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion YMES.Logics/MES/TagPrint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public override void AfterBaseFormLoad(EventArgs e)
if (dt.Rows.Count > 0)
{
StatusBarMsg(FX.MainForm.Base.Common.MsgTypeEnum.Alarm, "Data Count : " + dt.Rows.Count.ToString());

yDataGridView1.SetValue(dt);
}
FrmMsgBox(FX.MainForm.Base.Common.MsgTypeEnum.Error, "Do you want to know?", "Test");
}


Expand Down
4 changes: 4 additions & 0 deletions YMES.Logics/YMES.Logics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\YMES.FX.Controls\YMES.FX.Controls.csproj">
<Project>{EEB8537A-5930-4F60-8984-34E2F08A5BCC}</Project>
<Name>YMES.FX.Controls</Name>
</ProjectReference>
<ProjectReference Include="..\YMES.FX.Forms\YMES.FX.MainForm.csproj">
<Project>{b9ad1929-d4cf-4253-8dad-1b8df38a36fd}</Project>
<Name>YMES.FX.MainForm</Name>
Expand Down

0 comments on commit 5aa10c9

Please sign in to comment.