页面树结构
转至元数据结尾
转至元数据起始

基于任务的帮助部分假设你已经熟悉如何在VisualStudio .NET环境下编程并且已经对如何使用C1Input控件有了一般地了解。如果你对theComponentOneInputforWinForms产品是个新手,请先阅读适用于WinForm上输入的入门。
.每个主题都对使用InputforWinForms产品的特殊任务提供了一个解决方案。通过下面每个主题的一步一步描述,你将能够使用各种各样的InputforWinForms特性创建项目。
每个基于任务的帮助主题同时假设你已经创建了一个新的.NET项目。

添加一个下拉列表

要给你的程序添加一个下拉列表,需要完成下面几个步骤:

  1. 右键点击你的程序(位置在SolutionExplorer中)并且从Add二级菜单中选择Add New Item。

  1. 在Add NewItem对话框里,从右边方框中Templates列表里选择WindowsForm。然后在Name文本框中输入

DropDownForm1.cs。

  1. 下面的步骤是在DropDownForm的代码中用下列类定义行替换原来的代码:

Visual Basic

Visual Basic

Public Class DropDownForm1
Inherits System.Windows.Forms.Form

C#

C#

Public Class DropDownForm1:System.Windows.Forms.Form

替换成:
Visual Basic

Visual Basic

Public Class DropDownForm1
Inherits C1.Win.C1Input.DropDownForm

C#

C#

Public Class DropDownForm1: C1.Win.C1Input.DropDownForm

表单编辑前应该类似下面的样子:

在导航器中改变导航

要在导航器中改变导航,象下面所示的改变索引:
Visual Basic

Visual Basic

Private Sub c1DbNavigator1_BeforeAction(sender As Object, e As
C1.Win.C1Input.NavigatorBeforeActionEventArgs)
If e.Button = C1.Win.C1Input.NavigatorButtonEnum.First Then ' Goto second record instead of the first e.Index = 1 End If

' Go to the last row if user entered too large position
If e.Button = C1.Win.C1Input.NavigatorButtonEnum.Position AndAlso e.Cancel
Then
e.Cancel = False End If
End Sub

C#

C#

private void c1DbNavigator1_BeforeAction(object sender,
C1.Win.C1Input.NavigatorBeforeActionEventArgs e) { if (e.Button == C1.Win.C1Input.NavigatorButtonEnum.First)
{

// Goto second record instead of the first e.Index = 1; }

// Go to the last row if user entered too large position if (e.Button == C1.Win.C1Input.NavigatorButtonEnum.Position && e.Cancel) {
e.Cancel = false; }
}

定制下拉编辑器

下面的下拉列表包含选择按钮和按钮控件以供用户从C1DropDownControl.中做选择。下拉列表外观属性已经被编辑过所以显示成下面的样子:

在你的C1DropDownControl控件的DropDownFormClassName属性中选择列表的类名(例如,
WindowsApplication1.DropDownForm1)。注意当你运行程序并且选择下拉箭头,下拉列表就会显示出来了。让下拉列表上的按钮控件有效

  1. 分别设定你的DropDownForm1上的button1和button2的AcceptButton和CancelButton属性。
  2. 选择OK按钮并且设定DialogResult属性为OK。同样,选择Cancel按钮并且设定DialogResult属性为Cancel。
  3. 当用户点击一个条目后,想要下拉列表关闭时改变控件的文字,添加下面的事件处理程序到PostChanges事件:

Visual Basic

Visual Basic

Private Sub DropDownForm1_PostChanges(sender As Object, e As System.EventArgs)
If (MyBase.DialogResult = DialogResult.OK) Then
Dim control1 As Control
For Each control1 In MyBase.Controls
If (TypeOf control1 is RadioButton AndAlso CType(control1,
RadioButton).Checked) Then
MyBase.OwnerControl.Value = CType(control1, RadioButton).Text
End If
Next
End If
End Sub

C#

C#

private void DropDownForm1_PostChanges(object sender, System.EventArgs e) { if (DialogResult == DialogResult.OK) { foreach (Control control1 in Controls) { if (control1 as RadioButton != null &&
((RadioButton)control1).Checked)
{
OwnerControl.Value = ((RadioButton)control1).Text;
}
}
}
}

  1. 在设计时,选择DropDownForm1在属性窗口查看它的属性,并且从属性工具栏框选择Events按钮
  2. 设定DropDownForm1.PostChanges事件为DropDownForm1_PostChanges.

  1. 当列表打开时,想要OK按钮(button1)获得焦点,设定DropDownForm1.FocusControl属性为button1。
  2. 要让Standard选择按钮选择上,在设计时选择radiobutton1按钮并且设定它的Checked属性为True。

这个主题的结果如下图:

你的列表应该显示成下面的样子。

  • 无标签