User manual

Chapter 4 Programming Examples RIGOL
DP700 Programming Guide 4-7
Visual C# Programming Example
Program used in this instance: Microsoft Visual Studio 2010
Functions realized in this stance: turning on the channel output.
1. Run Microsoft Visual Studio 2010 and create a standard application project (WindowsFormsApplication)
named DP700_DEMO_C#.
2. Add "serialPort" and other controls.
3. Click "COM1" to add an event "comBox_MouseClick".
/// <summary>
/// Available serial port
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comBox_MouseClick(object sender, MouseEventArgs e)
{
bool bcomExist = false;
comBox.Items.Clear();
for (int i = 0; i < 15; i++)
{
try
{
SerialPort sp = new SerialPort("COM" + (i + 1).ToString());
sp.Open();
sp.Close();
comBox.Items.Add("COM" + (i + 1).ToString());
bcomExist = true;
}
catch (Exception)
{
continue;
}
}
if (bcomExist)
{
comBox.SelectedIndex = 0;
}
else