控件的用法ComboBox;RadionButton;Timer;DataGridView

ComboBox:组合框---属性:

Text:选中的值

Items:组合框中的项

Add:添加单个的值

AddRange:添加多个的值

SelectedIndex:索引值  

SelectedValue:隐藏值                                                                  

DropDownStyle:下拉框样式

Remove:删除

Clear:清除

例:

//选中文本框的值

var txt=this.ComboBox.Text;

//添加单个的值

this.ComboBox.Add("小黑");

//添加多个的值

string[]strs={"小黑","小米"};

this.ComboBox.AddRange("小黑");

//选中第一个值

this.ComboBox.SelectedIndex=0;

//隐藏值

this.ComboBox.SelectedValue=;

//获取隐藏值

var sReceivablesType = cbo_ReceivablesType.SelectedValue;

//下拉框样式设置为只读

this.ComboBox.DropDownStyle=ComboBoxStyle.DropDownList;

//删除选中的值

this.ComboBox = Items.Remove(txt);

//清除选中的值

this.ComboBox = Items.Clear(txt);

//一个List<类>的数据源 获取户型
var housesTypeList = HousesTypeProxyService.GetInstance().GetListByBuildSysNoToDropList(BuildingSysNo);
if (housesTypeList == null)
         return;

//绑定数据源

cbo_UnitInfo.DisplayMember = "UnitName";
            cbo_UnitInfo.ValueMember = "SysNo";
            cbo_UnitInfo.DataSource = housesUnitList;

 //获取下拉框选中的Dto类

 var list = cbo_UnitInfo.DataSource as List<HousesTypeDto>; //取得户型
            if (list == null) return;
            var index = cbo_Odd.SelectedIndex;
            var housesTypeDto = list[index];

---事件:SelectedIndexChanged:下拉框列表发生改变时触发的事件

RadionButton:单选按钮---属性:

Checked:是否选中

例:

if(this.RadionButton.Checked){

  MessagerBox.Show("选中");

}else{

  MessagerBox.Show("没选中");

}                                                                                             

Timer:时钟控件---属性:

InterVal:时间间隔,单位是毫秒

Enavles:开启时钟

例:

//获取当前时间

DateTime dt=DateTime.Now;

//开启时钟

this.timerl.Start();

//设置时间间隔

this.timerl.InterVal=1000;

//停止时钟

this.timerl.stop();

DataGridView:黑道

绑定值:this.DataGridView.DataSource=table;

选中值:this.DataGridView.SelectedItems[0].Cells[0].Valus.tostring();

 获取当前选择的一行SysNo属性的值:var sysNo = dgv_MessageList.CurrentRow.Cells["SysNo"].Value.ToString();

原文地址:https://www.cnblogs.com/denglj/p/3841041.html