このチュートリアルでは、境界線の設定、スクロールトラッキングおよびスクロールヒントについて学びます。
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
Me.CustomerTableAdapter.Fill(Me.DsCustomer.Customer) |
C# コードの書き方
C# |
コードのコピー
|
---|---|
this.CustomerTableAdapter.Fill(this.DsCustomer.Customer); |
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
' データをコピーします。 Dim dbTable As DataTable Dim borderColor As Color Dim borderLeft As Integer, borderTop As Integer, borderRight As Integer, borderBottom As Integer Dim borderType As C1.Win.C1TrueDBGrid.BorderTypeEnum |
C# コードの書き方
C# |
コードのコピー
|
---|---|
// データをコピーします。 DataTable dbTable; Color borderColor; int borderLeft, int borderTop, int borderRight, int borderBottom; C1.Win.C1TrueDBGrid.BorderTypeEnum borderType; |
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
dbTable = Me.DsCustomer.Tables(0).Copy() ' 各コントロールを初期化します。 FillComboBox1() FillCombo(ComboBox2) FillCombo(ComboBox3) FillCombo(ComboBox4) FillCombo(ComboBox5) Me.CheckBox2.Checked = True ' 境界線を初期化します。 Me.borderBottom = 1 Me.borderLeft = 1 Me.borderRight = 1 Me.borderTop = 1 |
C# コードの書き方
C# |
コードのコピー
|
---|---|
dbTable = this.DsCustomer.Tables[0].Copy(); // 各コントロールを初期化します。 FillComboBox1(); FillCombo(comboBox2); FillCombo(comboBox3); FillCombo(comboBox4); FillCombo(comboBox5); this.checkBox2.Checked = true; // 境界線を初期化します。 this.borderBottom = 1; this.borderLeft = 1; this.borderRight = 1; this.borderTop = 1; |
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
' コンボボックスに値を挿入します。 Private Sub FillCombo(ByRef com As ComboBox) Dim i As Integer com.Text = 1 For i = 1 To 10 com.Items.Add(i) Next End Sub ' コンボボックスに境界線の種類を挿入します。 Private Sub FillComboBox1() Me.ComboBox1.Text = "None" With Me.ComboBox1.Items .Add("Fillet") .Add("Flat") .Add("Groove") .Add("Inset") .Add("InsetBevel") .Add("None") .Add("Raised") .Add("RaisedBevel") End With End Sub |
C# コードの書き方
C# |
コードのコピー
|
---|---|
// コンボボックスに値を挿入します。 private void FillCombo(ref ComboBox com) { int i; com.Text = 1; for (i = 1 ; i <= 10; i++) { com.Items.Add[I]; } } // コンボボックスに境界線の種類を挿入します。 private void FillComboBox1() { this.comboBox1.Text = "None"; this.comboBox1.Items.Add("Fillet"); this.comboBox1.Items.Add("Flat"); this.comboBox1.Items.Add("Groove"); this.comboBox1.Items.Add("Inset"); this.comboBox1.Items.Add("InsetBevel"); this.comboBox1.Items.Add("None"); this.comboBox1.Items.Add("Raised"); this.comboBox1.Items.Add("RaisedBevel"); } |
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim result As DialogResult result = Me.ColorDialog1.ShowDialog() If result = DialogResult.OK Then borderColor = Me.ColorDialog1.Color Button1.BackColor = borderColor End If UpdateBorder() End Sub |
C# コードの書き方
C# |
コードのコピー
|
---|---|
private void button1_Click(System.object sender, System.EventArgs e) button1.Click { DialogResult result; result = this.colorDialog1.ShowDialog(); if (result == DialogResult.OK ) { borderColor = this.colorDialog1.Color; button1.BackColor = borderColor; } UpdateBorder(); } |
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
Private Sub UpdateBorder() With Me.C1TrueDBGrid1.Splits(0).DisplayColumns(Me.C1TrueDBGrid1.Col).Style.Borders .Color = ColorDialog1.Color .BorderType = borderType .Bottom = borderBottom .Left = borderLeft .Right = borderRight .Top = borderTop End With End Sub |
C# コードの書き方
C# |
コードのコピー
|
---|---|
private void UpdateBorder() { C1.Win.C1TrueDBGrid.GridBorders b; b = this.c1TrueDBGrid1.Splits[0].DisplayColumns(this.c1TrueDBGrid1.Col).Style.Borders; b.Color = colorDialog1.Color; b.BorderType = borderType; b.Bottom = borderBottom; b.Left = borderLeft; b.Right = borderRight; b.Top = borderTop; } |
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectionChangeCommitted Select Case Me.ComboBox1.SelectedItem Case "Fillet" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Fillet Case "Flat" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Flat Case "Groove" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Groove Case "Inset" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Inset Case "InsetBevel" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.InsetBevel Case "None" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.None Case "Raised" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Raised Case "RaisedBevel" Me.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.RaisedBevel End Select Me.UpdateBorder() End Sub Private Sub ComboBox2_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectionChangeCommitted Me.borderTop = Me.ComboBox2.SelectedItem Me.UpdateBorder() End Sub Private Sub ComboBox3_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectionChangeCommitted Me.borderBottom = Me.ComboBox3.SelectedItem Me.UpdateBorder() End Sub Private Sub ComboBox4_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectionChangeCommitted Me.borderLeft = Me.ComboBox4.SelectedItem Me.UpdateBorder() End Sub Private Sub ComboBox5_SelectionChangeCommitted(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectionChangeCommitted Me.borderRight = Me.ComboBox5.SelectedItem Me.UpdateBorder() End Sub |
C# コードの書き方
C# |
コードのコピー
|
---|---|
private void ComboBox1_SelectionChangeCommitted(object sender, System.EventArgs e) { switch (this.comboBox1.SelectedItem) { case "Fillet"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Fillet; break; case "Flat"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Flat; break; case "Groove"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Groove; break; case "Inset"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Inset; break; case "InsetBevel"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.InsetBevel; break; case "None"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.None; break; case "Raised"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.Raised; break; case "RaisedBevel"; this.borderType = C1.Win.C1TrueDBGrid.BorderTypeEnum.RaisedBevel; break; } this.UpdateBorder(); } private void comboBox2_SelectionChangeCommitted(object sender, System.EventArgs e) { this.borderTop = this.comboBox2.SelectedItem; this.UpdateBorder(); } private void comboBox3_SelectionChangeCommitted(object sender, System.EventArgs e) { this.borderBottom = this.comboBox3.SelectedItem; this.UpdateBorder(); } private void comboBox4_SelectionChangeCommitted(object sender, System.EventArgs e) { this.borderLeft = this.comboBox4.SelectedItem; this.UpdateBorder(); } private void comboBox5_SelectionChangeCommitted(object sender, System.EventArgs e) { this.borderRight = this.comboBox5.SelectedItem; this.UpdateBorder(); } |
Visual Basic コードの書き方
Visual Basic |
コードのコピー
|
---|---|
Private Sub CheckBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox1.Click Me.C1TrueDBGrid1.ScrollTips = Me.CheckBox1.Checked End Sub Private Sub CheckBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CheckBox2.Click Me.C1TrueDBGrid1.ScrollTrack = Me.CheckBox2.Checked End Sub Private Sub C1TrueDBGrid1_FetchScrollTips(ByVal sender As System.Object, ByVal e As C1.Win.C1TrueDBGrid.FetchScrollTipsEventArgs) Handles C1TrueDBGrid1.FetchScrollTips ' 移動されたスクロールバーにScrollTipを設定します。 Select Case e.ScrollBar Case C1.Win.C1TrueDBGrid.ScrollBarEnum.Horizontal e.ScrollTip = Me.C1TrueDBGrid1.Columns(e.ColIndex).Caption Case C1.Win.C1TrueDBGrid.ScrollBarEnum.Vertical e.ScrollTip = "Record: " & CStr(e.Row + 1) & " of " & CStr(Me.dbTable.Rows.Count) & vbCrLf & "Company: " & Me.dbTable.Rows(e.Row).Item("Company") & vbCrLf & "User code: " & Me.dbTable.Rows(e.Row).Item("UserCode") End Select e.TipStyle.ForeColor = Color.Blue End Sub |
C# コードの書き方
C# |
コードのコピー
|
---|---|
private void checkBox1_Click(object sender, System.EventArgs e) { this.c1TrueDBGrid1.ScrollTips = this.checkBox1.Checked; } private void checkBox2_Click(object sender, System.EventArgs e) { this.c1TrueDBGrid1.ScrollTrack = this.checkBox2.Checked; } private void c1TrueDBGrid1_FetchScrollTips(System.object sender, C1.Win.C1TrueDBGrid.FetchScrollTipsEventArgs e) { // 移動されたスクロールバーにScrollTipを設定します。 switch (e.ScrollBar) { case C1.Win.C1TrueDBGrid.ScrollBarEnum.Horizontal: e.ScrollTip = this.c1TrueDBGrid1.Columns[e.ColIndex].Caption; break; case C1.Win.C1TrueDBGrid.ScrollBarEnum.Vertical: e.ScrollTip = "Record: " + (e.Row + 1).ToString() + " of " + this.dbTable.Rows.Count.ToString() + "\n" + "Company: " + this.dbTable.Rows[e.Row]["Company"].ToString() + "\n" + "User code: " + this.dbTable.Rows[e.Row]["UserCode"].ToString(); break; } e.TipStyle.ForeColor = Color.Blue; } |
これでチュートリアル 22 は終了です。