サンプルアプリ
ヘルプにあったプログラムを元にサンプルプログラムを作成してみました
今回のは只の雛型プログラムです、これをテンプレに必要な項目を選び肉付けすれば簡単なアプリが作成できると思います
アプリのパーツや型の感じがつかめると思うので色々試してみて下さい
(使用の際には表示-EL印刷ログを表示して下さい)
あとは大きさ、数、色、レイアウトや細かい設定等、クリックした項目に応じて必要な処理等、エラー対応等、ELで作成すればOKです
アプリとインジケータやショーミ―等の一番の大きな違いは
自由な枠組みを作れるかどうか!そこだけだと思いました(今のところ)
自由なだけにレイアウトとかセンスが問われますが、
でも基本殆どがエクセル型ですw
色んな情報を表示出来るのがレーダースクリーン、
売買実績を表示するタイム&セールス、
板と出来高を表示するマトリックスって感じです
気付くと型的には殆どエクセルのような表計算タイプで同じですが、
表示するデータによって随分違うアプリに感じていた気がします(๑°o°๑)
ヘルプのアプリは、イニシャライズイベントに
フォームやグリッドを細かく設定出来ていました
フォームはEL開発環境で右クリック-フォーム追加でイニシャライズイベントの中に入れる事が出来ましたが、細かい変更や設定が分かりませんでした
コンポーネントもチェックが入ってるにも関わらず
Winformの所には出てこないし良くわかりません(´д`;)
興味のある人は、ヘルプアプリのジェネレーションコードを表示してみるとフォームやグリッドが細かく設定されてるのが分かります
今回は殆ど設定していませんが、細かく設定しようとすればフォームとグリッドの設定だけで更に100ステップ弱必要という事になります
参考元 !ex_DataGridViewSampleリンク
http://help.tradestation.com/09_05/Monex/jpn/tsdevhelp/Subsystems/elobject/example/!ex_datagridviewsample.eld
オブジェクト指向プログラミングは開発手法の1つ!
人其々の理解度と解釈で、色々な比喩や例えで余計分かりにくくしている
オブジェクト指向 (object oriented)
オブジェクト指向プログラミングは、
「オブジェクト(もの)中心に考えるソフトウエア開発手法」
ソフトウエア全体として機能を実現するだけでなく、
保守性や再利用性に配慮して、個々の部品の独立性も重視する
従来の開発手法は、「機能中心」
最初に全体として実現する機能を定義し、徐々に細分化していく
「構造化分析/設計開発手法」とし体系化され長い間主流として使われてきた
プログラム
//クラス参照宣言
using elsystem; //tsdataクラスによって使用される基本クラスと、その他一般的なelsystemクラス
using elsystem.windows.forms; //フォームのコントロールおよびコンテナーの作成に使用されるクラス
using elsystem.drawing; //フォームコントロールやドローイングオブジェクトの色およびフォント特性を記述するために使用されるクラス
variables: //変数宣言 フォームや表、タブ、ボタン、ボックス、辞書等の宣言
Form Form1( null ), //フォーム Formクラス
TabControl Tab( null ), TabPage TPage1( null ), TabPage TPage2( null ), //タブ TabControlクラス
DataGridView DGV1( null ), //表 DataGridViewクラス
DataGridViewButtonColumn BtnCol( null ), //ボタン DataGridViewButtonColumnクラス
DataGridViewCheckBoxColumn ChkBoxcol( null ), //チェックボックス DataGridViewCheckBoxColumnクラス
DataGridViewComboBoxColumn ComBoxcol( null ), //コンボボックス DataGridViewComboBoxColumnクラス
DataGridViewDateTimePickerColumn DTPcol( null ), //日時ピッカー DataGridViewDateTimePickerColumnクラス
DataGridViewLinkColumn Linkcol( null ), //リンク DataGridViewLinkColumnクラス
DataGridViewNumericUpDownColumn NUDcol( null ), //数値アップダウン DataGridViewNumericUpDownColumnクラス
DataGridViewTextBoxColumn Tboxcol( null ), //テキストボックス DataGridViewTextBoxColumnクラス
DataGridViewColumn Textcol( null ), //テキスト DataGridViewColumnクラス
DataGridViewRow Row1( null ), //行 DataGridViewRowクラス
DataGridViewColumn Col1( null ); //列 DataGridViewColumnクラス
{ -------------------------------------------------- } //※ 検証する時に、プロパティでイニシャライズイベントに設定
method void AnalysisTechnique_Initialized( elsystem.Object sender, elsystem.InitializedEventArgs args )
begin
Clearprintlog(); //印刷ログを削除
SelectGrid(); //パーツの設定・選択
Form1.Show(); //フォームを表示
end;{ method AnalysisTechnique_Initialized }
{ -------------------------------------------------- } //パーツの設定・選択
method void SelectGrid()
begin
//パーツの初期設定・表示
Form_Column(); //フォーム
Tab_Column(); //タブ
DGV_Column(); //表
Button_Column(); //ボタン
Checkbox_Column(); //チェックボックス
Combobox_Column(); //コンボボックス
DateTimePicker_Column(); //日時ピッカー
Linkcol_Column(); //リンク
NumericUpDown_Column(); //数値アップダウン
Textbox_Column(); //テキストボックス
Text_Column(); //文字、数値
Col1_Column(); //列
//例
DGV1.Columns.Add( "例1" ); //見出し例1
DGV1.Columns.Add( "列1" ); //列追加
for Value1 = 0 to 9 begin //9列処理
if Value1 <= 1 then begin
Row1_Column(); //行 初期設定
Row1.Cells[0].Value = "Button " + NumToStr(Value1, 0);
Row1.Cells[1].Value = True;
Row1.Cells[2].Value = "None";
Row1.Cells[2].ToolTipText = "選択してちょ!";
Row1.Cells[3].Value = DateTime.Create(2017, 8, Value1);
Row1.Cells[4].Value = "Link " + NumToStr(Value1, 0);
Row1.Cells[5].Value = Value1;
Row1.Cells[6].Value = "サンプルだよ";
Row1.Cells[7].Value = Value1;
Row1.Cells[8].Value = Value1;
Row1.Cells[9].Value = "プリントログ削除";
end;
end;
end; { SelectGrid }
{ -------------------------------------------------- } //フォーム初期設定
method void Form_Column()
begin
Form1 = Form.Create(); //フォームの新規インスタンスを初期化
Form1.Dock = DockStyle.Fill; //フォームのコントロールがドッキングされる位置および方法を指定
end; { Form_Column }
{ -------------------------------------------------- } //タブ初期設定
method void Tab_Column()
begin
Tab = TabControl.Create(); //TabControlクラス、TabControlの新規インスタンスを初期化
Form1.AddControl( Tab ); //フォームにタブのコントロールを追加
Tab1_Column(); //タブ1処理
Tab2_Column(); //タブ2処理
Tab.Dock = DockStyle.Fill; //コントロールがドッキングされる位置および方法を指定 ヘルプDockStyle列挙参照
end; { Tab_Column }
{ -------------------------------------------------- } //タブ1処理
method void Tab1_Column()
begin
TPage1 = TabPage.Create( "タブ名1",0,0 ); //TabPageクラス、TabPageの新規インスタンスを初期化(text,width,height)※ タブの横、高さ機能していない
Tab.AddControl( TPage1 ); //TabControlクラス、TPage1のコントロールをタブに追加
end; { Tab1_Column }
{ -------------------------------------------------- } //タブ2処理
method void Tab2_Column()
begin
TPage2 = TabPage.Create( "タブ名2",0,0 ); //TabPageクラス、TabPageの新規インスタンスを初期化(text,width,height)※ タブの横、高さ機能していない
Tab.AddControl( TPage2 ); //TabControlクラス、TPage2のコントロールをタブに追加
end; { Tab2_Column }
{ -------------------------------------------------- } //表初期設定
method void DGV_Column()
begin
DGV1 = DataGridView.Create(); //DataGridViewクラス、DGV1の新規インスタンスを初期化
TPage1.AddControl( DGV1 ); //DGV1表をTPage1のコントロールに追加
DGV1.Dock = DockStyle.Fill; //DGV1のコントロールがドッキングされる位置および方法を指定
DGV1.AllowUserToAddRows = false; //ユーザーがグリッド行を追加できる場合はtrue/false
DGV1.ColumnHeadersDefaultCellStyle.Alignment //ヘッダーのデフォルトのスタイルを取得または設定
= DataGridViewContentAlignment.MiddleCenter; //フォームコントロール内のテキストの整列
end; { DGV_Column }
{ -------------------------------------------------- } //ボタン初期設定
method void Button_Column()
begin
Btncol = DataGridViewButtonColumn.Create( "ボタン" ); //見出し
Btncol.SortMode = DataGridViewColumnSortMode.Automatic; //ソート
Btncol.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;//列幅
DGV1.Columns.Add( Btncol );
end; { Button_Column }
{ -------------------------------------------------- } //チェックボックス初期設定
method void Checkbox_Column()
begin
Chkboxcol = DataGridViewCheckBoxColumn.Create( "チェックボックス" );
Chkboxcol.SortMode = DataGridViewColumnSortMode.Automatic;
Chkboxcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
DGV1.Columns.Add( Chkboxcol );
end; { Checkbox_Column }
{ -------------------------------------------------- } //コンボボックス初期設定
method void Combobox_Column()
begin
Comboxcol = DataGridViewComboBoxColumn.Create( "コンボボックス" );
Comboxcol.SortMode = DataGridViewColumnSortMode.Automatic;
Comboxcol.Items.AddRange( "None", "A", "B", "C", "D", "E" );
Comboxcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
DGV1.Columns.Add( Comboxcol );
end; { Combobox_Column }
{ -------------------------------------------------- } //日時ピッカー初期設定
method void DateTimePicker_Column()
begin
DTPcol = DataGridViewDateTimePickerColumn.Create( "日時ピッカー" );
DTPcol.SortMode = DataGridViewColumnSortMode.NotSortable; //※ ソート禁止!100%トレステクラッシュする
DTPcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
DGV1.Columns.Add( DTPcol );
end; { DateTimePicker_Column }
{ -------------------------------------------------- } //リンク初期設定
method void Linkcol_Column()
begin
Linkcol = DataGridViewLinkColumn.Create( "リンク" );
Linkcol.SortMode = DataGridViewColumnSortMode.Automatic;
Linkcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
DGV1.Columns.Add( Linkcol );
end; { Link_Column }
{ -------------------------------------------------- } //数値アップダウン初期設定
method void NumericUpDown_Column()
begin
NUDcol = DataGridViewNumericUpDownColumn.Create( "数値アップダウン" );
NUDcol.SortMode = DataGridViewColumnSortMode.NotSortable; //※ ソート禁止!100%トレステクラッシュする
NUDcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
DGV1.ColumnHeadersDefaultCellStyle.BackColor = elsystem.drawing.SystemColors.Control;
DGV1.Columns.Add( NUDcol );
end; { NumericUpDown_Column }
{ -------------------------------------------------- } //テキストボックス初期設定
method void TextBox_Column()
begin
TBoxcol = DataGridViewTextBoxColumn.Create( "テキストボックス" );
TBoxcol.SortMode = DataGridViewColumnSortMode.Automatic;
TBoxcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
DGV1.Columns.Add( TBoxcol );
end; { TextBox_Column }
{ -------------------------------------------------- } //テキスト初期設定
method void Text_Column()
begin
Textcol = DataGridViewColumn.Create( "テキスト" );
Textcol.SortMode = DataGridViewColumnSortMode.Automatic;
Textcol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
Textcol.ReadOnly = True; //ユーザーが列のセルを編集できない場合はtrue/false
DGV1.Columns.Add( Textcol );
end; { Text_Column }
{ -------------------------------------------------- } //列初期設定
method void Col1_Column()
begin
Col1 = DataGridViewColumn.Create( "" ); //DataGridViewColumnクラス、Colの新規インスタンスを初期化
Col1.SortMode = DataGridViewColumnSortMode.Automatic; //列のソートモードを取得または設定
// DGV1.Columns.clear(); //列クリア
end; { Col1_Column }
{ -------------------------------------------------- } //行初期設定
method void Row1_Column()
begin
Row1 = DataGridViewRow.Create( "" ); //DataGridViewRowクラス、Rowの新規インスタンスを初期化
DGV1.Rows.Add( Row1 ); //行追加
// DGV1.Rows.clear(); //行クリア
end; { Row1_Column }
{ -------------------------------------------------- } //選択処理
//セルをクリックした時
method void DGV1_CellClick( elsystem.Object sender, elsystem.windows.forms.DataGridViewCellEventArgs args )
begin
print("セルをクリック: 行=", args.RowIndex, " 列=", args.ColumnIndex);
{ ボタンを押した時 }
if ( args.ColumnIndex = 0 and args.RowIndex >= 0 ) then begin
print( DGV1.Rows[args.RowIndex].Cells[0].Text, " クリック", args.RowIndex, " 行の状態を印刷" );
print( "チェックボックス選択 ", DGV1.Rows[args.RowIndex].Cells[1].Value.ToString() );
print( "コンボボックス選択 ", DGV1.Rows[args.RowIndex].Cells[2].Text );
print( "日時ピッカー選択 ", DGV1.Rows[args.RowIndex].Cells[3].Value.ToString() );
print( "数値アップダウン選択 ", DGV1.Rows[args.RowIndex].Cells[5].Value.ToString() );
print( "テキストボックス ", args.RowIndex, " ", DGV1.Rows[args.RowIndex].Cells[6].Value.ToString() );
print( "テキスト ", DGV1.Rows[args.RowIndex].Cells[7].Value.ToString() );
print( "例1 ", DGV1.Rows[args.RowIndex].Cells[8].Value.ToString() );
switch DGV1.Rows[args.RowIndex].Cells[2].Text begin
case "None": print( "コンボNone処理 " ); break;
case "A": print( "コンボ A 処理 " ); break;
case "B": print( "コンボ B 処理 " ); break;
case "C": print( "コンボ C 処理 " ); break;
case "D": print( "コンボ D 処理 " ); break;
case "E": print( "コンボ E 処理 " ); break;
end;
end;
{ 列9を押した時 }
if ( args.ColumnIndex = 9 and args.RowIndex >= 0 ) then begin
Clearprintlog(); //印刷ログを削除
end;
end; { DGV1_CellClick }
//選択を変えた時
method void DGV1_SelectionChanged( elsystem.Object sender, elsystem.EventArgs args )
begin
print( "選択変更: ", DGV1.SelectedCells.Count, " セル選択" );
end;
//値を変えた時
method void DGV1_CellValueChanged( elsystem.Object sender, elsystem.windows.forms.DataGridViewCellEventArgs args )
begin
print( "値変更: 行=", args.RowIndex, " 列=", args.ColumnIndex );
end;
//列ヘッダーをクリックした時
method void DGV1_ColumnHeaderMouseClick( elsystem.Object sender, elsystem.windows.forms.DataGridViewCellMouseEventArgs args )
begin
print( "列ヘッダーをクリック: 行=", args.RowIndex, " 列=", args.ColumnIndex);
end;
//行ヘッダーをクリックした時
method void DGV1_RowHeaderMouseClick( elsystem.Object sender, elsystem.windows.forms.DataGridViewCellMouseEventArgs args )
begin
print( "行ヘッダーをクリック: 行=", args.RowIndex, " 列=", args.ColumnIndex);
end;
//ソートした時
method void DGV1_SortCompare( elsystem.Object sender, elsystem.windows.forms.DataGridViewSortCompareEventArgs args )
begin
print( "ソート: 行=", args.RowIndex1, " 値=", args.CellValue1.ToString(),
" 行=", args.RowIndex2, " 値=", args.CellValue2.ToString() );
end;
{ -------------------------------------------------- } //選択処理
DGV1.cellclick += DGV1_cellclick; //セルをクリックした時
DGV1.cellvaluechanged += DGV1_cellvaluechanged; //値を変えた時
DGV1.columnheadermouseclick += DGV1_columnheadermouseclick; //列ヘッダーをクリックした時
DGV1.rowheadermouseclick += DGV1_rowheadermouseclick; //行ヘッダーをクリックした時
DGV1.selectionchanged += DGV1_selectionchanged; //選択を変えた時
DGV1.sortcompare += DGV1_sortcompare; //ソートした時
{ -------------------------------------------------- }
{ フォームやグリッドの初期設定:サンプル元のイニシャライズイベントにあったデザイナージェネレーションコード
DGV1.GridColor = elsystem.drawing.Color.FromArgb(160, 160, 160);
DGV1.BorderStyle = elsystem.windows.forms.BorderStyle.FixedSingle;
DGV1.GradientMode = elsystem.windows.forms.LinearGradientMode.ForwardDiagonal;
DGV1.ColumnHeadersHeight = 23;
DGV1.ColumnHeadersVisible = true;
DGV1.ColumnHeadersFont = elsystem.drawing.Font.Create("Microsoft Sans Serif", 8.25, 0);
DGV1.ColumnHeadersBorderStyle = elsystem.windows.forms.DataGridViewHeaderBorderStyle.Raised;
DGV1.ColumnHeadersDefaultCellStyle.Alignment = elsystem.windows.forms.DataGridViewContentAlignment.MiddleLeft;
DGV1.ColumnHeadersDefaultCellStyle.BackColor = elsystem.drawing.SystemColors.Control;
DGV1.ColumnHeadersDefaultCellStyle.Font = elsystem.drawing.Font.Create("Microsoft Sans Serif", 8.25, 0);
DGV1.ColumnHeadersDefaultCellStyle.ForeColor = elsystem.drawing.SystemColors.WindowText;
DGV1.ColumnHeadersDefaultCellStyle.SelectionBackColor = elsystem.drawing.SystemColors.Highlight;
DGV1.ColumnHeadersDefaultCellStyle.SelectionForeColor = elsystem.drawing.SystemColors.HighlightText;
DGV1.ColumnHeadersDefaultCellStyle.WrapMode = elsystem.windows.forms.DataGridViewTriState.True;
DGV1.RowHeadersWidth = 41;
DGV1.RowHeadersVisible = true;
DGV1.RowHeadersFont = elsystem.drawing.Font.Create("Microsoft Sans Serif", 8.25, 0);
DGV1.RowHeadersBorderStyle = elsystem.windows.forms.DataGridViewHeaderBorderStyle.Raised;
DGV1.RowHeadersDefaultCellStyle.Alignment = elsystem.windows.forms.DataGridViewContentAlignment.MiddleLeft;
DGV1.RowHeadersDefaultCellStyle.BackColor = elsystem.drawing.SystemColors.Control;
DGV1.RowHeadersDefaultCellStyle.Font = elsystem.drawing.Font.Create("Microsoft Sans Serif", 8.25, 0);
DGV1.RowHeadersDefaultCellStyle.ForeColor = elsystem.drawing.SystemColors.WindowText;
DGV1.RowHeadersDefaultCellStyle.SelectionBackColor = elsystem.drawing.SystemColors.Highlight;
DGV1.RowHeadersDefaultCellStyle.SelectionForeColor = elsystem.drawing.SystemColors.HighlightText;
DGV1.RowHeadersDefaultCellStyle.WrapMode = elsystem.windows.forms.DataGridViewTriState.True;
DGV1.AllowUserToAddRows = false;
DGV1.CellBorderStyle = elsystem.windows.forms.DataGridViewCellBorderStyle.Single;
DGV1.ReadOnly = false;
DGV1.SelectionMode = elsystem.windows.forms.DataGridViewSelectionMode.CellSelect;
DGV1.MultiSelect = true;
DGV1.DefaultCellStyle.Alignment = elsystem.windows.forms.DataGridViewContentAlignment.MiddleLeft;
DGV1.DefaultCellStyle.BackColor = elsystem.drawing.SystemColors.Window;
DGV1.DefaultCellStyle.Font = elsystem.drawing.Font.Create("Microsoft Sans Serif", 8.25, 0);
DGV1.DefaultCellStyle.ForeColor = elsystem.drawing.Color.Black;
DGV1.DefaultCellStyle.SelectionBackColor = elsystem.drawing.SystemColors.Highlight;
DGV1.DefaultCellStyle.SelectionForeColor = elsystem.drawing.SystemColors.HighlightText;
DGV1.DefaultCellStyle.WrapMode = elsystem.windows.forms.DataGridViewTriState.False;
DGV1.AlternatingRowsDefaultCellStyle.Alignment = elsystem.windows.forms.DataGridViewContentAlignment.NotSet;
DGV1.AlternatingRowsDefaultCellStyle.Font = elsystem.drawing.Font.Create("Microsoft Sans Serif", 8.00, 0);
DGV1.AlternatingRowsDefaultCellStyle.WrapMode = elsystem.windows.forms.DataGridViewTriState.NotSet;
DGV1.EnableHeadersVisualStyles = true;
DGV1.Text = "DGV1";
DGV1.Width = 284;
DGV1.Height = 434;
DGV1.Dock = elsystem.windows.forms.DockStyle.Fill;
DGV1.Enabled = true;
DGV1.BackColor = elsystem.drawing.Color.FromArgb(171, 171, 171);
DGV1.ForeColor = elsystem.drawing.Color.Black;
DGV1.Margin = new elsystem.windows.forms.Padding( 3, 3, 3, 3 );
DGV1.Font = elsystem.drawing.Font.Create("Microsoft Sans Serif", 8.25, 0);
DGV1.ControlLocation.X = 0;
DGV1.ControlLocation.Y = 0;
DGV1.RightToLeft = elsystem.windows.forms.RightToLeft.No;
DGV1.Name = "DGV1";
}