Bài giảng C# 2010 - Chapter 2: Windows Form and Windows Forms Controls (Part 4)

 private void btnLoadHeader_Click

(object sender, EventArgs e)

 {

 ColumnHeader hdID = new

 ColumnHeader();

 hdID.Text = "ID";

 ColumnHeader hdName = new

 ColumnHeader();

 hdName.Text = "Name";

 ColumnHeader hdBirthday = new

 ColumnHeader();

 hdBirthday.Text = "Birthday";

 

pptx15 trang | Chuyên mục: Visual C# | Chia sẻ: dkS00TYs | Lượt xem: 1883 | Lượt tải: 1download
Tóm tắt nội dung Bài giảng C# 2010 - Chapter 2: Windows Form and Windows Forms Controls (Part 4), để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
Click to edit Master title style Click to edit Master text styles Second level Third level Fourth level Fifth level 13/05/2013 ‹#› btnHeader btnAdd btnRemove lvDataDn txtID txtName dateBirthDay ListView private void btnLoadHeader_Click (object sender, EventArgs e) { 	ColumnHeader hdID = new 	ColumnHeader(); 	hdID.Text = "ID"; 	ColumnHeader hdName = new 	ColumnHeader(); hdName.Text = "Name"; 	ColumnHeader hdBirthday = new 	ColumnHeader(); 	hdBirthday.Text = "Birthday"; lvDataDn.GridLines = true; lvDataDn.FullRowSelect = true; lvDataDn.MultiSelect = true; lvDataDn.HideSelection = false; lvDataDn.View = View.Details; hdID.Width = 100; hdName.Width =140; hdBirthday.Width = 140; lvDataDn.Columns.Clear(); lvDataDn.Columns.AddRange(new ColumnHeader[] { hdID,hdName,hdBirthday}); } At Design Time ???? private void btnAdd_Click (object sender, EventArgs e) { ListViewItem itemID = new 	ListViewItem(); itemID.Text = txtID.Text; ListViewItem.ListViewSubItem itemName = new ListViewItem.ListViewSubItem(); itemName.Text=txtName.Text; itemID.SubItems.Add(itemName); ListViewItem.ListViewSubItem itemBirthday = new ListViewItem.ListViewSubItem(); itemBirthday.Text = dateBirthDay.Value.Day + "/" + dateBirthDay.Value.Month + "/" + dateBirthDay.Value.Year; itemID.SubItems.Add(itemBirthday); lvDataDn.Items.Add(itemID); } private void btnRemove_Click (object sender, EventArgs e) {ListView. SelectedListViewItemCollection list = lvDataDn.SelectedItems; foreach (ListViewItem item in list) 	lvDataDn.Items.Remove(item); } ListView.SelectedIndexCollection indices = lvDataDn.SelectedIndices; foreach (int index in indices) { 	//Process Index here } We could use Indices TreeView ImageList SelectedNode TreeNode ImageIndex SelectedImageIndex Nodes Remove Add Expand Collapse Popular Properties & Method private void frmTreeView_Load (object sender, EventArgs e) {cboImageIndex.Items.Clear(); for (int i = 0; i < imgList.Images.Count;i++ ) { cboImageIndex.Items.Add(i); } tvSample.ImageList = imgList; } private void btnAddRoot_Click (object sender, EventArgs e) {tvSample.Nodes.Clear(); TreeNode rootNode = new TreeNode(txtRoot.Text); rootNode.ImageIndex = Int32.Parse(cboImageIndex.Text); rootNode.SelectedImageIndex = rootNode.ImageIndex; tvSample.Nodes.Add(rootNode); txtRoot.Text = ""; } private void cboImageIndex_SelectedIndexChanged(object sender, EventArgs e) { picShow.Image=imgList.Images[Int32.Parse(cboImageIndex.Text)]; } private void btnRemove_Click(object sender, EventArgs e) { TreeNode tNode = tvSample.SelectedNode; tvSample.Nodes.Remove(tNode); } END 

File đính kèm:

  • pptxBài giảng C# 2010 - Chapter 2 Windows Form and Windows Forms Controls (Part 4).pptx