如何绑定combo box的显示数据
1个回答
展开全部
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Collections;
namespace ClientDemo
{
public partial class Setting : Office2007Form
{
private int start;
private int process;
private int end;
private int faceQuality;
private int faceConfidence;
private int processIncrement;
private int endIncrement;
private int interval;
private int resolution;
public Setting()
{
InitializeComponent();
/// <summary>
/// 0=CIF, 1=QCIF, 2=D1 3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA
/// IPCAM专用{3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA(640x480) , 7=XVGA, 8=HD900p }
/// </summary>
ArrayList al = new ArrayList();
al.Add(new TextAndValue("CIF(352*288)", "0"));
al.Add(new TextAndValue("QCIF(176*144)", "1"));
al.Add(new TextAndValue("4CIF(704*576)", "2"));
al.Add(new TextAndValue("UXGA(1600*1200)", "3"));
al.Add(new TextAndValue("SVGA(800*600)", "4"));
al.Add(new TextAndValue("HD720P(1280*720)", "5"));
al.Add(new TextAndValue("VGA(640*480)", "6"));
al.Add(new TextAndValue("XVGA(1280*960)", "7"));
al.Add(new TextAndValue("HD900P(1600*912)", "8"));
cboResolution.DataSource = al;
cboResolution.DisplayMember = "DisplayText";
cboResolution.ValueMember = "RealValue";
}
private void Setting_Load(object sender, EventArgs e)
{
DBColection.getConfigList();
foreach (DBColection.TraceConfig tc in DBColection.configList)
{
if (tc.ParamType == "Start") txtMinStartTraceStart.Text = tc.Start.ToString();
else if (tc.ParamType == "Process")
{
txtMinStartTraceProcess.Text = tc.Start.ToString();
nudProcessIncrement.Value = (decimal)tc.Step;
}
else if (tc.ParamType == "End")
{
txtMinStartTraceEnd.Text = tc.Start.ToString();
nudEndIncrement.Value = (decimal)tc.Step;
}
else if (tc.ParamType == "FaceQuality") txtFaceQuality.Text = tc.Start.ToString();
else if (tc.ParamType == "FaceConfidence") txtFaceConfidence.Text = tc.Start.ToString();
else if (tc.ParamType == "Interval") txtInterval.Text = tc.Start.ToString();
else if (tc.ParamType == "Resolution")
cboResolution.SelectedValue = tc.Start.ToString();
}
}
private void btncancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnok_Click(object sender, EventArgs e)
{
start = Convert.ToInt32(txtMinStartTraceStart.Text.Trim().ToString());
process = Convert.ToInt32(txtMinStartTraceProcess.Text.Trim().ToString());
end = Convert.ToInt32(txtMinStartTraceEnd.Text.Trim().ToString());
faceQuality = Convert.ToInt32(txtFaceQuality.Text.Trim().ToString());
faceConfidence = Convert.ToInt32(txtFaceConfidence.Text.Trim().ToString());
processIncrement = Convert.ToInt32(nudProcessIncrement.Value.ToString());
endIncrement = Convert.ToInt32(nudEndIncrement.Value.ToString());
interval = Convert.ToInt32(txtInterval.Text.Trim().ToString());
resolution = Convert.ToInt16(cboResolution.SelectedValue.ToString());
DBColection.updateConfigList(start, process, end, faceQuality, faceConfidence, processIncrement, endIncrement, interval, resolution);
}
private void cboResolution_SelectedIndexChanged(object sender, EventArgs e)
{
resolution = Convert.ToInt16(cboResolution.SelectedValue.ToString());
}
}
class TextAndValue
{
private string _RealValue = "";
private string _DisplayText = "";
public string DisplayText
{
get
{
return _DisplayText;
}
}
public string RealValue
{
get
{
return _RealValue;
}
}
public TextAndValue(string ShowText, string RealVal)
{
_DisplayText = ShowText;
_RealValue = RealVal;
}
public override string ToString()
{
return _RealValue.ToString();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Collections;
namespace ClientDemo
{
public partial class Setting : Office2007Form
{
private int start;
private int process;
private int end;
private int faceQuality;
private int faceConfidence;
private int processIncrement;
private int endIncrement;
private int interval;
private int resolution;
public Setting()
{
InitializeComponent();
/// <summary>
/// 0=CIF, 1=QCIF, 2=D1 3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA
/// IPCAM专用{3=UXGA(1600x1200), 4=SVGA(800x600), 5=HD720p(1280x720),6=VGA(640x480) , 7=XVGA, 8=HD900p }
/// </summary>
ArrayList al = new ArrayList();
al.Add(new TextAndValue("CIF(352*288)", "0"));
al.Add(new TextAndValue("QCIF(176*144)", "1"));
al.Add(new TextAndValue("4CIF(704*576)", "2"));
al.Add(new TextAndValue("UXGA(1600*1200)", "3"));
al.Add(new TextAndValue("SVGA(800*600)", "4"));
al.Add(new TextAndValue("HD720P(1280*720)", "5"));
al.Add(new TextAndValue("VGA(640*480)", "6"));
al.Add(new TextAndValue("XVGA(1280*960)", "7"));
al.Add(new TextAndValue("HD900P(1600*912)", "8"));
cboResolution.DataSource = al;
cboResolution.DisplayMember = "DisplayText";
cboResolution.ValueMember = "RealValue";
}
private void Setting_Load(object sender, EventArgs e)
{
DBColection.getConfigList();
foreach (DBColection.TraceConfig tc in DBColection.configList)
{
if (tc.ParamType == "Start") txtMinStartTraceStart.Text = tc.Start.ToString();
else if (tc.ParamType == "Process")
{
txtMinStartTraceProcess.Text = tc.Start.ToString();
nudProcessIncrement.Value = (decimal)tc.Step;
}
else if (tc.ParamType == "End")
{
txtMinStartTraceEnd.Text = tc.Start.ToString();
nudEndIncrement.Value = (decimal)tc.Step;
}
else if (tc.ParamType == "FaceQuality") txtFaceQuality.Text = tc.Start.ToString();
else if (tc.ParamType == "FaceConfidence") txtFaceConfidence.Text = tc.Start.ToString();
else if (tc.ParamType == "Interval") txtInterval.Text = tc.Start.ToString();
else if (tc.ParamType == "Resolution")
cboResolution.SelectedValue = tc.Start.ToString();
}
}
private void btncancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnok_Click(object sender, EventArgs e)
{
start = Convert.ToInt32(txtMinStartTraceStart.Text.Trim().ToString());
process = Convert.ToInt32(txtMinStartTraceProcess.Text.Trim().ToString());
end = Convert.ToInt32(txtMinStartTraceEnd.Text.Trim().ToString());
faceQuality = Convert.ToInt32(txtFaceQuality.Text.Trim().ToString());
faceConfidence = Convert.ToInt32(txtFaceConfidence.Text.Trim().ToString());
processIncrement = Convert.ToInt32(nudProcessIncrement.Value.ToString());
endIncrement = Convert.ToInt32(nudEndIncrement.Value.ToString());
interval = Convert.ToInt32(txtInterval.Text.Trim().ToString());
resolution = Convert.ToInt16(cboResolution.SelectedValue.ToString());
DBColection.updateConfigList(start, process, end, faceQuality, faceConfidence, processIncrement, endIncrement, interval, resolution);
}
private void cboResolution_SelectedIndexChanged(object sender, EventArgs e)
{
resolution = Convert.ToInt16(cboResolution.SelectedValue.ToString());
}
}
class TextAndValue
{
private string _RealValue = "";
private string _DisplayText = "";
public string DisplayText
{
get
{
return _DisplayText;
}
}
public string RealValue
{
get
{
return _RealValue;
}
}
public TextAndValue(string ShowText, string RealVal)
{
_DisplayText = ShowText;
_RealValue = RealVal;
}
public override string ToString()
{
return _RealValue.ToString();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询