The code below generates a combo_box that selects a channel, a check box to select hi/low, and a button to execute. What I've been trying to do for tha last 20 hours is make all of this one button. Instead of the checkbox, I'd like the output to go hi on buttondown and low on buttonup. I'd like to remove the combo box and just "hard wire" the first address (Dev1/Port0/line0) to button1. Can anyone help with the syntax? I don't know how this line "physicalChannelComboBox.Items.AddRange(DaqSystem.Local.GetPhysicalChannels(PhysicalChannelTypes.DOLine, PhysicalChannelAccess.External));" brings in the info "Dev1/Port0/line0" .
thanks
using
namespace
{
/// <summary>
/// Summary description for Mainform.
/// </summary>
public class MainForm : System.Windows.Forms.Form
private System.Windows.Forms.CheckBox bit0CheckBox;
private System.Windows.Forms.Label bit0Label;
private System.Windows.Forms.Button writeButton;
private System.Windows.Forms.ComboBox physicalChannelComboBox;
private System.ComponentModel.Container components = null;
public MainForm()
InitializeComponent();
physicalChannelComboBox.Items.AddRange(DaqSystem.Local.GetPhysicalChannels(PhysicalChannelTypes.DOLine, PhysicalChannelAccess.External));
}
protected override void Dispose( bool disposing )
if( disposing )
if (components != null)
components.Dispose();
base.Dispose( disposing );
#region
private void InitializeComponent()
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.writeButton = new System.Windows.Forms.Button();
this.bit0CheckBox = new System.Windows.Forms.CheckBox();
this.bit0Label = new System.Windows.Forms.Label();
this.physicalChannelComboBox = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// writeButton
this.writeButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.writeButton.Location = new System.Drawing.Point(63, 102);
this.writeButton.Name = "writeButton";
this.writeButton.Size = new System.Drawing.Size(80, 24);
this.writeButton.TabIndex = 0;
this.writeButton.Text = "&Write";
this.writeButton.Click += new System.EventHandler(this.WriteButton_Click);
// bit0CheckBox
this.bit0CheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.bit0CheckBox.Location = new System.Drawing.Point(19, 62);
this.bit0CheckBox.Name = "bit0CheckBox";
this.bit0CheckBox.Size = new System.Drawing.Size(16, 16);
this.bit0CheckBox.TabIndex = 6;
this.bit0CheckBox.Text = "Line0";
// bit0Label
this.bit0Label.Location = new System.Drawing.Point(16, 81);
this.bit0Label.Name = "bit0Label";
this.bit0Label.Size = new System.Drawing.Size(16, 16);
this.bit0Label.TabIndex = 5;
this.bit0Label.Text = "0";
// physicalChannelComboBox
this.physicalChannelComboBox.Location = new System.Drawing.Point(16, 24);
this.physicalChannelComboBox.Name = "physicalChannelComboBox";
this.physicalChannelComboBox.Size = new System.Drawing.Size(184, 21);
this.physicalChannelComboBox.TabIndex = 2;
this.physicalChannelComboBox.Text = "Dev1/Port0/line0";
this.physicalChannelComboBox.SelectedIndexChanged += new System.EventHandler(this.physicalChannelComboBox_SelectedIndexChanged);
// MainForm
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(216, 146);
this.Controls.Add(this.physicalChannelComboBox);
this.Controls.Add(this.bit0Label);
this.Controls.Add(this.bit0CheckBox);
this.Controls.Add(this.writeButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Write Dig Channel";
this.ResumeLayout(false);
#endregion
/// The main entry point for the application.
[STAThread]
static void Main()
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new MainForm());
private void WriteButton_Click(object sender, System.EventArgs e)
Cursor.Current = Cursors.WaitCursor;
try
using (Task digitalWriteTask = new Task())
digitalWriteTask.DOChannels.CreateChannel(physicalChannelComboBox.Text,"",
ChannelLineGrouping.OneChannelForAllLines);
bool[] dataArray = new bool[1];
dataArray[0] = bit0CheckBox.Checked;
DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(digitalWriteTask.Stream);
writer.WriteSingleSampleMultiLine(true, dataArray);
catch(DaqException ex)
MessageBox.Show(ex.Message);
finally
Cursor.Current = Cursors.Default;
private void button1_click(object sender, EventArgs e)
private void physicalChannelComboBox_SelectedIndexChanged(object sender, EventArgs e)