| List for WinForms Tutorials > Tutorial 16 Borders, Scroll Tracking and Scroll Tips |
In this tutorial, you will learn how to use the ScrollTips property and the FetchScrollTips event to provide a tip box as the user scrolls through a list. You will also learn to create borders and colored borders for each item.

To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.CustomerTableAdapter.Fill(Me.DsCustomer.Customer) |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.CustomerTableAdapter.Fill(this.DsCustomer.Customer); |
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Dim tb As DataTable Dim borderColor As Color Dim bLeft, bTop, bRight, bBottom As Integer Dim bType As C1.Win.C1List.BorderTypeEnum |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
DataTable tb; Color borderColor; int bLeft, bTop, bRight, bBottom; C1.Win.C1List.BorderTypeEnum bType; |
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
tb = Me.DsCustomer.Tables(0).Copy()
Me.C1List1.ItemHeight = 40
' Fill each combo.
Me.CheckBox2.Checked = True
FillCombo(C1Combo1)
FillCombo(C1Combo2)
FillCombo(C1Combo3)
FillCombo(C1Combo4)
FillCombo5()
' Initialize the border size.
bBottom = 1
bTop = 1
bLeft = 1
bRight = 1
bType = C1.Win.C1List.BorderTypeEnum.None
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
tb = this.DsCustomer.Tables[0].Copy();
this.c1List1.ItemHeight = 40;
// Fill each combo.
this.checkBox2.Checked = true;
FillCombo(C1Combo1);
FillCombo(C1Combo2);
FillCombo(C1Combo3);
FillCombo(C1Combo4);
FillCombo5();
// Initialize the border size.
bBottom = 1;
bTop = 1;
bLeft = 1;
bRight = 1;
bType = C1.Win.C1List.BorderTypeEnum.None;
|
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' Fill each combo with numbers from 1 to 10.
Private Sub FillCombo(ByRef combo As C1.Win.C1List.C1Combo)
Dim i As Integer
combo.DataMode = C1.Win.C1List.DataModeEnum.AddItem
For i = 1 To 10
combo.AddItem(i.ToString())
Next
combo.Text = 1
End Sub
Private Sub FillCombo5()
With Me.C1Combo5
.DataMode = C1.Win.C1List.DataModeEnum.AddItem
.AddItem("Fillet")
.AddItem("Flat")
.AddItem("Groove")
.AddItem("Inset")
.AddItem("InsetBevel")
.AddItem("None")
.AddItem("Raised")
.AddItem("RaisedBevel")
.SelectedIndex = 5
End With
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// Fill each combo with numbers from 1 to 10.
private void FillCombo(C1.Win.C1List.C1Combo combo)
{
int i;
combo.DataMode = C1.Win.C1List.DataModeEnum.AddItem;
for ( i =1 ; i <= 10 ; i++)
{
combo.AddItem(i.ToString());
}
combo.Text = 1;
}
private void FillCombo5()
{
this.C1Combo5..DataMode = C1.Win.C1List.DataModeEnum.AddItem;
this.C1Combo5.AddItem("Fillet");
this.C1Combo5.AddItem("Flat");
this.C1Combo5.AddItem("Groove");
this.C1Combo5.AddItem("Inset");
this.C1Combo5.AddIte("InsetBevel");
this.C1Combo5.AddItem("None");
this.C1Combo5.AddItem("Raised");
this.C1Combo5.AddItem("RaisedBevel");
this.C1Combo5.SelectedIndex = 5;
}
|
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
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
Me.borderColor = Me.ColorDialog1.Color
Me.Button1.BackColor = Me.borderColor
End If
UpdateBorder()
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void Button1_Click( System.object sender,
System.EventArgs e)
{
DialogResult result;
result = this.ColorDialog1.ShowDialog();
if ( result == DialogResult.OK )
{
this.borderColor = this.ColorDialog1.Color;
this.Button1.BackColor = this.borderColor;
}
UpdateBorder();
}
|
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub UpdateBorder()
If Me.C1List1.Splits(0).DisplayColumns(Me.C1List1.Col) Is Nothing Then
Exit Sub
End If
With Me.C1List1.Splits(0).DisplayColumns(Me.C1List1.Col).Style.Borders
.Color = Me.borderColor
.BorderType = Me.bType
.Bottom = Me.bBottom
.Left = Me.bLeft
.Right = Me.bRight
.Top = Me.bTop
End With
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void UpdateBorder()
{
if ( this.c1List1.Splits[0].DisplayColumns[this.c1List1.Col] == null )
{
return;
}
CellBorders borders = this.c1List1.Splits[0].DisplayColumns [this.c1List1.Col].Style.Borders;
borders.Color = this.borderColor;
borders.BorderType = this.bType;
borders.Bottom = this.bBottom;
borders.Left = this.bLeft;
borders.Right = this.bRight;
borders.Top = this.bTop;
}
|
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub C1Combo1_RowChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1Combo1.RowChange
Me.bTop = Me.C1Combo1.SelectedIndex + 1
Me.UpdateBorder()
End Sub
Private Sub C1Combo2_RowChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1Combo2.RowChange
Me.bBottom = Me.C1Combo2.SelectedIndex + 1
Me.UpdateBorder()
End Sub
Private Sub C1Combo3_RowChange(ByVal sender As Object, ByVal e As System.EventArgs)
Handles C1Combo3.RowChange
Me.bLeft = Me.C1Combo3.SelectedIndex + 1
Me.UpdateBorder()
End Sub
Private Sub C1Combo4_RowChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1Combo4.RowChange
Me.bRight = Me.C1Combo4.SelectedIndex + 1
Me.UpdateBorder()
End Sub
Private Sub C1Combo5_RowChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1Combo5.RowChange
Select Case Me.C1Combo5.Text
Case "Fillet"
Me.bType = C1.Win.C1List.BorderTypeEnum.Fillet
Case "Flat"
Me.bType = C1.Win.C1List.BorderTypeEnum.Flat
Case "Groove"
Me.bType = C1.Win.C1List.BorderTypeEnum.Groove
Case "Inset"
Me.bType = C1.Win.C1List.BorderTypeEnum.Inset
Case "InsetBevel"
Me.bType = C1.Win.C1List.BorderTypeEnum.InsetBevel
Case "None"
Me.bType = C1.Win.C1List.BorderTypeEnum.None
Case "Raised"
Me.bType = C1.Win.C1List.BorderTypeEnum.Raised
Case "RaisedBevel"
Me.bType = C1.Win.C1List.BorderTypeEnum.RaisedBevel
End Select
Me.UpdateBorder()
End Sub
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void C1Combo1_RowChange( object sender, System.EventArgs e)
{
this.bTop = this.C1Combo1.SelectedIndex + 1;
this.UpdateBorder();
}
private void C1Combo2_RowChange( object sender, System.EventArgs e)
{
this.bBottom = this.C1Combo2.SelectedIndex + 1;
this.UpdateBorder();
}
private void C1Combo3_RowChange( object sender, System.EventArgs e)
{
this.bLeft = this.C1Combo3.SelectedIndex + 1;
this.UpdateBorder();
}
private void C1Combo4_RowChange( object sender, System.EventArgs e)
{
this.bRight = this.C1Combo4.SelectedIndex + 1;
this.UpdateBorder();
}
private void C1Combo5_RowChange( object sender, System.EventArgs e)
{
switch (this.C1Combo5.Text) {
case "Fillet":
this.bType = C1.Win.C1List.BorderTypeEnum.Fillet;
break;
case "Flat":
this.bType = C1.Win.C1List.BorderTypeEnum.Flat;
break;
case "Groove":
this.bType = C1.Win.C1List.BorderTypeEnum.Groove;
break;
case "Inset":
this.bType = C1.Win.C1List.BorderTypeEnum.Inset;
break;
case "InsetBevel":
this.bType = C1.Win.C1List.BorderTypeEnum.InsetBevel;
break;
case "None":
this.bType = C1.Win.C1List.BorderTypeEnum.None;
break;
case "Raised":
this.bType = C1.Win.C1List.BorderTypeEnum.Raised;
break;
case
"RaisedBevel":
this.bType = C1.Win.C1List.BorderTypeEnum.RaisedBevel;
break;
}
this.UpdateBorder();
}
|
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Private Sub CheckBox1_Click(ByVal sender As Object, Private Sub CheckBox2_Click(ByVal sender As Object, Private Sub C1List1_FetchScrollTips(ByVal sender As Object,
' Set the ScrollTip depending on which scroll bar was moved.
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
private void CheckBox1_Click( object sender, |
|

![]() |
Note: When C1Combo has the focus, press F4 to open the drop-down box. |

This concludes the tutorial.