Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 16 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
16
Dung lượng
295,47 KB
Nội dung
DONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGY ListView btnHeader lvDataDn btnAdd txtID txtName btnRemove dateBirthDay DONG NAI UNIVERSITY OF TECHNOLOGY 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"; DONG NAI UNIVERSITY OF TECHNOLOGY 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(); DONG NAI UNIVERSITY OF TECHNOLOGY lvDataDn.Columns.AddRange(new ColumnHeader[] { hdID,hdName,hdBirthday}); } At Design Time ???? DONG NAI UNIVERSITY OF TECHNOLOGY private void btnAdd_Click (object sender, EventArgs e) { ListViewItem itemID = new ListViewItem(); itemID.Text = txtID.Text; ListViewItem.ListViewSubItem itemName ListViewItem.ListViewSubItem(); itemName.Text=txtName.Text; itemID.SubItems.Add(itemName); = new ListViewItem.ListViewSubItem itemBirthday = new DONG NAI UNIVERSITY OF TECHNOLOGY ListViewItem.ListViewSubItem(); itemBirthday.Text = dateBirthDay.Value.Day + "/" + dateBirthDay.Value.Month + "/" + dateBirthDay.Value.Year; itemID.SubItems.Add(itemBirthday); lvDataDn.Items.Add(itemID); } DONG NAI UNIVERSITY OF TECHNOLOGY private void btnRemove_Click (object sender, EventArgs e) {ListView SelectedListViewItemCollection list = lvDataDn.SelectedItems; foreach (ListViewItem item in list) lvDataDn.Items.Remove(item); } DONG NAI UNIVERSITY OF TECHNOLOGY We could use Indices ListView.SelectedIndexCollection indices = lvDataDn.SelectedIndices; foreach (int index in indices) { //Process Index here } DONG NAI UNIVERSITY OF TECHNOLOGY TreeVie w DONG NAI UNIVERSITY OF TECHNOLOGY Popular Properties ImageList & Method ImageIndex SelectedImageIndex TreeNode SelectedNode Add Nodes Remove Expand Collapse DONG NAI UNIVERSITY OF TECHNOLOGY 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 DONG NAI UNIVERSITY OF TECHNOLOGY (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 = ""; } DONG NAI UNIVERSITY OF TECHNOLOGY private void cboImageIndex_SelectedIndexChanged(object sender, EventArgs e) { picShow.Image=imgList.Images[Int32.Parse(cboImageIndex.Text )]; } DONG NAI UNIVERSITY OF TECHNOLOGY private void btnRemove_Click(object sender, EventArgs e) { TreeNode tNode = tvSample.SelectedNode; tvSample.Nodes.Remove(tNode); } DONG NAI UNIVERSITY OF TECHNOLOGY END [...]... btnAddRoot_Click DONG NAI UNIVERSITY OF TECHNOLOGY (object sender, EventArgs e) {tvSample.Nodes.Clear(); TreeNode rootNode = new TreeNode(txtRoot.Text); rootNode.ImageIndex = Int 32. Parse(cboImageIndex.Text); rootNode.SelectedImageIndex = rootNode.ImageIndex; tvSample.Nodes.Add(rootNode); txtRoot.Text = ""; } DONG NAI UNIVERSITY OF TECHNOLOGY private void cboImageIndex_SelectedIndexChanged(object sender,...DONG NAI UNIVERSITY OF TECHNOLOGY Popular Properties ImageList & Method ImageIndex SelectedImageIndex TreeNode SelectedNode Add Nodes Remove Expand Collapse DONG NAI UNIVERSITY OF TECHNOLOGY 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... private void cboImageIndex_SelectedIndexChanged(object sender, EventArgs e) { picShow.Image=imgList.Images[Int 32. Parse(cboImageIndex.Text )]; } DONG NAI UNIVERSITY OF TECHNOLOGY private void btnRemove_Click(object sender, EventArgs e) { TreeNode tNode = tvSample.SelectedNode; tvSample.Nodes.Remove(tNode); } DONG NAI UNIVERSITY OF TECHNOLOGY END ... DONG NAI UNIVERSITY OF TECHNOLOGY We could use Indices ListView.SelectedIndexCollection indices = lvDataDn.SelectedIndices; foreach (int index in indices) { //Process Index here } DONG NAI UNIVERSITY... lvDataDn.Items.Add(itemID); } DONG NAI UNIVERSITY OF TECHNOLOGY private void btnRemove_Click (object sender, EventArgs e) {ListView SelectedListViewItemCollection list = lvDataDn.SelectedItems; foreach (ListViewItem... = 140 ; hdBirthday.Width = 140 ; lvDataDn.Columns.Clear(); DONG NAI UNIVERSITY OF TECHNOLOGY lvDataDn.Columns.AddRange(new ColumnHeader[] { hdID,hdName,hdBirthday}); } At Design Time ???? DONG NAI