C#报错“System.Windows.Forms.ListView”不包含“SubItems”的定义

错误 1 “System.Windows.Forms.ListView”不包含“SubItems”的定义,并且找不到可接受类型为“System.Windows.Forms.ListView”的第一个参数的扩展方法“SubItems”(是否缺少 using 指令或程序集引用?) C:\Users\WamgHong\Desktop\net1203汪洪\WindowsFormsApplication1\WindowsFormsApplication1\FormOpratorManager.cs 25 32 WindowsFormsApplication1

c#
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
关于一个C#的窗口的状态栏 问题
![图片说明](https://img-ask.csdn.net/upload/201812/13/1544661249_375562.png) ![图片说明](https://img-ask.csdn.net/upload/201812/13/1544661258_649422.png) 状态栏我设置两个,结果就显示出一个,为什么呢?以下是design代码 namespace 窗体的综合 { partial class FormMain { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.系统ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.学生ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.st1 = new System.Windows.Forms.ToolStripStatusLabel(); this.st2 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.treeView1 = new System.Windows.Forms.TreeView(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.listView1 = new System.Windows.Forms.ListView(); this.listBox1 = new System.Windows.Forms.ListBox(); this.menuStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 // this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.系统ToolStripMenuItem, this.学生ToolStripMenuItem, this.帮助ToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(688, 28); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // // 系统ToolStripMenuItem // this.系统ToolStripMenuItem.Name = "系统ToolStripMenuItem"; this.系统ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.系统ToolStripMenuItem.Text = "系统"; // // 学生ToolStripMenuItem // this.学生ToolStripMenuItem.Name = "学生ToolStripMenuItem"; this.学生ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.学生ToolStripMenuItem.Text = "学生"; // // 帮助ToolStripMenuItem // this.帮助ToolStripMenuItem.Name = "帮助ToolStripMenuItem"; this.帮助ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.帮助ToolStripMenuItem.Text = "帮助"; // // toolStrip1 // this.toolStrip1.AutoSize = false; this.toolStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripButton2, this.toolStripButton3, this.toolStripButton1}); this.toolStrip1.Location = new System.Drawing.Point(0, 28); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(688, 103); this.toolStrip1.TabIndex = 1; this.toolStrip1.Text = "toolStrip1"; // // toolStripButton2 // this.toolStripButton2.AutoSize = false; this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(100, 100); this.toolStripButton2.Text = "toolStripButton2"; // // toolStripButton3 // this.toolStripButton3.AutoSize = false; this.toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(100, 100); this.toolStripButton3.Text = "toolStripButton3"; // // toolStripButton1 // this.toolStripButton1.AutoSize = false; this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image"))); this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton1.Name = "toolStripButton1"; this.toolStripButton1.Size = new System.Drawing.Size(100, 100); this.toolStripButton1.Text = "toolStripButton1"; // // statusStrip1 // this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.st1, this.st2, this.toolStripStatusLabel1}); this.statusStrip1.Location = new System.Drawing.Point(0, 512); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(688, 29); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // // st1 // this.st1.AutoToolTip = true; this.st1.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom))); this.st1.BorderStyle = System.Windows.Forms.Border3DStyle.Bump; this.st1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.st1.ImageAlign = System.Drawing.ContentAlignment.BottomLeft; this.st1.Name = "st1"; this.st1.Size = new System.Drawing.Size(317, 24); this.st1.Spring = true; this.st1.Text = " "; this.st1.Click += new System.EventHandler(this.toolStripStatusLabel1_Click); // // st2 // this.st2.AutoToolTip = true; this.st2.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom))); this.st2.BorderStyle = System.Windows.Forms.Border3DStyle.Adjust; this.st2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.st2.ImageAlign = System.Drawing.ContentAlignment.BottomRight; this.st2.Name = "st2"; this.st2.Size = new System.Drawing.Size(317, 24); this.st2.Spring = true; this.st2.Click += new System.EventHandler(this.st2_Click); // // toolStripStatusLabel1 // this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 24); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 131); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.Controls.Add(this.treeView1); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); this.splitContainer1.Size = new System.Drawing.Size(688, 381); this.splitContainer1.SplitterDistance = 229; this.splitContainer1.TabIndex = 3; // // treeView1 // this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; this.treeView1.Location = new System.Drawing.Point(0, 0); this.treeView1.Name = "treeView1"; this.treeView1.Size = new System.Drawing.Size(229, 381); this.treeView1.TabIndex = 0; // // splitContainer2 // this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer2.Location = new System.Drawing.Point(0, 0); this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; // // splitContainer2.Panel1 // this.splitContainer2.Panel1.Controls.Add(this.listView1); // // splitContainer2.Panel2 // this.splitContainer2.Panel2.Controls.Add(this.listBox1); this.splitContainer2.Panel2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.splitContainer2.Size = new System.Drawing.Size(455, 381); this.splitContainer2.SplitterDistance = 37; this.splitContainer2.TabIndex = 0; // // listView1 // this.listView1.Dock = System.Windows.Forms.DockStyle.Fill; this.listView1.Location = new System.Drawing.Point(0, 0); this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(455, 37); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; // // listBox1 // this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.listBox1.FormattingEnabled = true; this.listBox1.ItemHeight = 20; this.listBox1.Location = new System.Drawing.Point(0, 0); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(455, 340); this.listBox1.TabIndex = 0; // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(688, 541); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.toolStrip1); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; this.Name = "FormMain"; this.Text = "FormMain"; this.Load += new System.EventHandler(this.FormMain_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.splitContainer2.Panel1.ResumeLayout(false); this.splitContainer2.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); this.splitContainer2.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem 系统ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 学生ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 帮助ToolStripMenuItem; private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStripButton toolStripButton2; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel st1; private System.Windows.Forms.ToolStripStatusLabel st2; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.ToolStripButton toolStripButton3; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.ListView listView1; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.ToolStripButton toolStripButton1; } }
C#listview 返回items.index
为什么listview无论点哪行items.index都返回0 ``` private void Hide_ToolStripMenuItem_Click(object sender, EventArgs e) { //隐藏数据 if (MessageBox.Show("是否隐藏本条数据?", "提问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int i_index = is_check_fun(); string ttmid = listView1.Items[i_index].SubItems[0].Text; string userid = UserLoginInfo.CurrentUserInfo.Id.ToString(); string sql = string.Format("EXECUTE [ysjk].[dbo].[SP_Hide_Show_Data] '{0}' ,'{1}' ,1", userid, ttmid); try { SQLHelper.ExecuteSql(sql); MessageBox.Show("本条数据已经被隐藏,本数据背景将以淡紫色显示。"); listView1.Items[i_index].BackColor = ColorTranslator.FromHtml("#ccccff"); //listView1.Items[listView1.Items.IndexOfKey(ttmid)].BackColor = ColorTranslator.FromHtml("#ccccff"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } private int is_check_fun() { if (listView1.Items.Count <= 0) { MessageBox.Show("没有数据,不能操作!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return -1; } if (listView1.SelectedItems.Count <= 0) { MessageBox.Show("没有选中一项!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return -1; } int index = listView1.SelectedItems[0].Index; return index; } ```
关于C#的一个超高难度状态栏问题
![图片说明](https://img-ask.csdn.net/upload/201812/16/1544939817_933066.png) 为什么? namespace Windows窗体应用综合 { partial class FrmMain { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.系统ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.学生ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.增加ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.修改ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.删除ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.关于ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.btnAddStudent = new System.Windows.Forms.ToolStripButton(); this.btnUpdateStudent = new System.Windows.Forms.ToolStripButton(); this.toolStripButton4 = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.lblLoginUser = new System.Windows.Forms.ToolStripStatusLabel(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.treeView1 = new System.Windows.Forms.TreeView(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.lvStudent = new System.Windows.Forms.ListView(); this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.listBox1 = new System.Windows.Forms.ListBox(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.menuStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 // this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.系统ToolStripMenuItem, this.学生ToolStripMenuItem, this.帮助ToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1147, 28); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // // 系统ToolStripMenuItem // this.系统ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.退出ToolStripMenuItem}); this.系统ToolStripMenuItem.Name = "系统ToolStripMenuItem"; this.系统ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.系统ToolStripMenuItem.Text = "系统"; // // 退出ToolStripMenuItem // this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem"; this.退出ToolStripMenuItem.Size = new System.Drawing.Size(114, 26); this.退出ToolStripMenuItem.Text = "退出"; // // 学生ToolStripMenuItem // this.学生ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.增加ToolStripMenuItem, this.修改ToolStripMenuItem, this.删除ToolStripMenuItem}); this.学生ToolStripMenuItem.Name = "学生ToolStripMenuItem"; this.学生ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.学生ToolStripMenuItem.Text = "学生"; // // 增加ToolStripMenuItem // this.增加ToolStripMenuItem.Name = "增加ToolStripMenuItem"; this.增加ToolStripMenuItem.Size = new System.Drawing.Size(114, 26); this.增加ToolStripMenuItem.Text = "增加"; // // 修改ToolStripMenuItem // this.修改ToolStripMenuItem.Name = "修改ToolStripMenuItem"; this.修改ToolStripMenuItem.Size = new System.Drawing.Size(114, 26); this.修改ToolStripMenuItem.Text = "修改"; // // 删除ToolStripMenuItem // this.删除ToolStripMenuItem.Name = "删除ToolStripMenuItem"; this.删除ToolStripMenuItem.Size = new System.Drawing.Size(114, 26); this.删除ToolStripMenuItem.Text = "删除"; // // 帮助ToolStripMenuItem // this.帮助ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.关于ToolStripMenuItem}); this.帮助ToolStripMenuItem.Name = "帮助ToolStripMenuItem"; this.帮助ToolStripMenuItem.Size = new System.Drawing.Size(51, 24); this.帮助ToolStripMenuItem.Text = "帮助"; // // 关于ToolStripMenuItem // this.关于ToolStripMenuItem.Name = "关于ToolStripMenuItem"; this.关于ToolStripMenuItem.Size = new System.Drawing.Size(114, 26); this.关于ToolStripMenuItem.Text = "关于"; // // toolStrip1 // this.toolStrip1.ImageScalingSize = new System.Drawing.Size(48, 48); this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.btnAddStudent, this.btnUpdateStudent, this.toolStripButton4, this.toolStripSeparator1, this.toolStripButton3}); this.toolStrip1.Location = new System.Drawing.Point(0, 28); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(1147, 75); this.toolStrip1.TabIndex = 1; this.toolStrip1.Text = "toolStrip1"; // // btnAddStudent // this.btnAddStudent.Image = ((System.Drawing.Image)(resources.GetObject("btnAddStudent.Image"))); this.btnAddStudent.ImageTransparentColor = System.Drawing.Color.Magenta; this.btnAddStudent.Name = "btnAddStudent"; this.btnAddStudent.Size = new System.Drawing.Size(73, 72); this.btnAddStudent.Text = "增加学生"; this.btnAddStudent.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; // // btnUpdateStudent // this.btnUpdateStudent.Image = ((System.Drawing.Image)(resources.GetObject("btnUpdateStudent.Image"))); this.btnUpdateStudent.ImageTransparentColor = System.Drawing.Color.Magenta; this.btnUpdateStudent.Name = "btnUpdateStudent"; this.btnUpdateStudent.Size = new System.Drawing.Size(73, 72); this.btnUpdateStudent.Text = "修改学生"; this.btnUpdateStudent.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; // // toolStripButton4 // this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image"))); this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton4.Name = "toolStripButton4"; this.toolStripButton4.Size = new System.Drawing.Size(73, 72); this.toolStripButton4.Text = "删除学生"; this.toolStripButton4.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 75); // // toolStripButton3 // this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(73, 72); this.toolStripButton3.Text = "退出系统"; this.toolStripButton3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; // // statusStrip1 // this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.lblLoginUser, this.toolStripStatusLabel1}); this.statusStrip1.Location = new System.Drawing.Point(0, 607); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(1147, 24); this.statusStrip1.TabIndex = 3; this.statusStrip1.Text = "statusStrip1"; this.statusStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.statusStrip1_ItemClicked); // // lblLoginUser // this.lblLoginUser.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom))); this.lblLoginUser.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenInner; this.lblLoginUser.Name = "lblLoginUser"; this.lblLoginUser.Size = new System.Drawing.Size(1093, 19); this.lblLoginUser.Spring = true; this.lblLoginUser.Click += new System.EventHandler(this.lblLoginUser_Click); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 103); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.Controls.Add(this.treeView1); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); this.splitContainer1.Size = new System.Drawing.Size(1147, 504); this.splitContainer1.SplitterDistance = 382; this.splitContainer1.TabIndex = 4; // // treeView1 // this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill; this.treeView1.Location = new System.Drawing.Point(0, 0); this.treeView1.Name = "treeView1"; this.treeView1.Size = new System.Drawing.Size(382, 504); this.treeView1.TabIndex = 0; // // splitContainer2 // this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer2.Location = new System.Drawing.Point(0, 0); this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; // // splitContainer2.Panel1 // this.splitContainer2.Panel1.Controls.Add(this.lvStudent); // // splitContainer2.Panel2 // this.splitContainer2.Panel2.Controls.Add(this.listBox1); this.splitContainer2.Size = new System.Drawing.Size(761, 504); this.splitContainer2.SplitterDistance = 294; this.splitContainer2.TabIndex = 0; // // lvStudent // this.lvStudent.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, this.columnHeader2, this.columnHeader3, this.columnHeader4, this.columnHeader5, this.columnHeader6}); this.lvStudent.Dock = System.Windows.Forms.DockStyle.Fill; this.lvStudent.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lvStudent.GridLines = true; this.lvStudent.Location = new System.Drawing.Point(0, 0); this.lvStudent.Name = "lvStudent"; this.lvStudent.Size = new System.Drawing.Size(761, 294); this.lvStudent.TabIndex = 0; this.lvStudent.UseCompatibleStateImageBehavior = false; this.lvStudent.View = System.Windows.Forms.View.Details; // // columnHeader1 // this.columnHeader1.Text = "学号"; this.columnHeader1.Width = 129; // // columnHeader2 // this.columnHeader2.Text = "姓名"; this.columnHeader2.Width = 100; // // columnHeader3 // this.columnHeader3.Text = "性别"; this.columnHeader3.Width = 80; // // columnHeader4 // this.columnHeader4.Text = "年级"; this.columnHeader4.Width = 100; // // columnHeader5 // this.columnHeader5.Text = "专业"; this.columnHeader5.Width = 100; // // columnHeader6 // this.columnHeader6.Text = "备注"; this.columnHeader6.Width = 300; // // listBox1 // this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.listBox1.FormattingEnabled = true; this.listBox1.ItemHeight = 15; this.listBox1.Location = new System.Drawing.Point(0, 0); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(761, 206); this.listBox1.TabIndex = 0; // // toolStripStatusLabel1 // this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; this.toolStripStatusLabel1.Size = new System.Drawing.Size(0, 19); // // FrmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1147, 631); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.toolStrip1); this.Controls.Add(this.menuStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; this.Name = "FrmMain"; this.Text = " "; this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); this.splitContainer2.Panel1.ResumeLayout(false); this.splitContainer2.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); this.splitContainer2.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem 系统ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 学生ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 增加ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 修改ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 删除ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 帮助ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 关于ToolStripMenuItem; private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStripButton btnAddStudent; private System.Windows.Forms.ToolStripButton btnUpdateStudent; private System.Windows.Forms.ToolStripButton toolStripButton4; private System.Windows.Forms.ToolStripButton toolStripButton3; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.TreeView treeView1; private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.ListView lvStudent; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.ToolStripStatusLabel lblLoginUser; private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader2; private System.Windows.Forms.ColumnHeader columnHeader3; private System.Windows.Forms.ColumnHeader columnHeader4; private System.Windows.Forms.ColumnHeader columnHeader5; private System.Windows.Forms.ColumnHeader columnHeader6; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; } }这是我删了第二个状态栏后,design代码
vb.net程序即vs2005中ListView没有Remove,如何来实现删除被选中的一行数据?
找了写资料,没有关于vb.net的Listview删除行的操作,哪位大拿指点指点。。。 vb.net程序提示"Remove"不是System.Windows.Forms.ListView的成员
python的kivy框架的第一个简单示例报错kivy.factory.FactoryException: Unknown class <ListView>?
最近在学习用python开发app,发现可以用kivy框架,按照教程上一模一样的代码编写却碰上报错,网上相关的资料实在是太少了,不知道怎么解决只好发到这里请各位大神帮忙看看。 下面是main.py代码: ``` from kivy.app import App class WeatherApp(App): pass if __name__ == '__main__': WeatherApp().run() ``` 下面是weather.kv代码: ``` AddLocationForm: <AddLocationForm@BoxLayout>: orientation: "vertical" BoxLayout: TextInput: Button: text: "Search" Button: text: "Current Location" ListView: item_strings: ["Palo Alto, MX", "Palo Alto, US"] ``` 结果运行后报错 kivy.factory.FactoryException: Unknown class 《ListView》 如果删除weather.kv代码中的 ``` ListView: item_strings: ["Palo Alto, MX", "Palo Alto, US"] ``` 则能够顺利运行,实在想不通组件ListView为什么会报错 python版本是3.7,kivy版本是1.11,win7上运行。 求教
C# 用户控件的Load事件不能执行
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net; using System.Net.Sockets; using System.Security.Cryptography; using System.IO; using OpenPOP.POP3; using System.Collections; using OpenPOP.MIMEParser; using System.Threading; using mymail.sqlDao; using System.Data.SqlClient; using mymail; namespace mymail { public partial class inbox : UserControl { public inbox() { InitializeComponent(); } private void inbox_Load(object sender, EventArgs e) { msgs.Clear(); //listMessages.Nodes.Clear();//邮件列表 listAttachments.Nodes.Clear();//附件列表 listView1.Clear();//清除空间中所有项 //button2.Enabled = false; //button3.Enabled = false; //ReceiveMails(); }
请问如何调用ListView1.ColumnClick
请问如何调用ListView1.ColumnClick Private Sub Sort_ColumnClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick ... End Sub 请问如何用button来调用这个函数?想点一下button然后listview的特定列排序,谢谢
c#里面listview控件调用
c#中listview控件的add方法怎么调用?就是显示出一列的数据!
c#在使用listview时,直接在ItemTemplate中放了文本控件,在页面提交时后面用item.FindControl取到的文本控件值为空
c#在使用listview时,直接在ItemTemplate中放了文本控件,在页面提交时后面用item.FindControl取到的文本控件值为空,但用网页开发工具看提交的参数是有控件中的值的,请问后台要怎取控件的值? 这是前端listview模版,说明绑定值的可以取到值,手动添加的TEXBOX控件取不到值 <ItemTemplate> <tr style=""> <td> <asp:Label ID="tiaomubianhaoLabel" runat="server" Text='<%# Eval("tiaomubianhao") %>' /> </td> <td> <asp:Label ID="chanpingtuhaoLabel" runat="server" Text='<%# Eval("chanpingtuhao") %>' /> </td> <td> <asp:Label ID="chanpingnameLabel" runat="server" Text='<%# Eval("chanpingname") %>' /> </td> <td> <asp:Label ID="daichuliangLabel" runat="server" Text='<%# Eval("daichuliang") %>' /> </td> <td> <asp:TextBox ID="jihuachushu" runat="server"></asp:TextBox> </td> <td> <asp:TextBox ID="jihuariqi" runat="server" TextMode="Date"></asp:TextBox> </td> <td> <asp:TextBox ID="beizhu" runat="server"></asp:TextBox> </td> </tr> </ItemTemplate> 下面是后面取值代码:后面三个TEXTBOX取得到控件,但值为 for (int i = 0; i < ListView1.Items.Count(); i++) { ListViewDataItem item = ListView1.Items[i]; Label tmbh = (Label)item.FindControl("tiaomubianhaoLabel"); Label cptuhao = (Label)item.FindControl("chanpingtuhaoLabel"); Label cpname = (Label)item.FindControl("chanpingnameLabel"); TextBox chsl = (TextBox)item.FindControl("jihuachushu"); TextBox chsj = (TextBox)item.FindControl("jihuariqi"); TextBox beizhu = (TextBox)item.FindControl("beizhu"); }
c# 线程间操作无效 从不是创建控件“listView1”的线程访问它
![图片说明](https://img-ask.csdn.net/upload/201912/02/1575253835_918613.jpg) private void button2_Click(object sender, EventArgs e) { Lrcload ld = new Lrcload(); ld.code = Encoding.Default; if (dcgb2312.Checked) ld.code = System.Text.Encoding.GetEncoding("gb2312"); if (dcutf8.Checked) ld.code = System.Text.Encoding.GetEncoding("utf-8"); ld.listview = listView1.Items; ld.reload = checkBox3.Checked; //ld.load(); Thread t = new Thread(new ThreadStart(ld.load)); t.IsBackground = true; t.Start(); } class Lrcload { /// <summary> /// 保存文件编码 /// </summary> public System.Text.Encoding code; /// <summary> /// 列表listview.Items /// </summary> // public ListViewItem[] listview; public ListView.ListViewItemCollection listview; /// <summary> /// 已有歌词重下 /// </summary> public bool reload; /// <summary> /// 下载歌词 /// </summary> public void load() { bu(false); foreach (ListViewItem lvi in listview) { try {
c#如何调listview图标间距
c#如何调listview的大图标的间距?大神请指点。比如largeicon的图标间距。注:改变图片大小对间距无作用。
C# listview checkbox 换行
在C#设计中,在listview中添加checkbox,每个checkbox的长度太长,怎么让文字可以换行啊? 各位大神。求助啊
用c#语言,为什么在listview中一直显示不了,语句没报错
ListView Lvl = new ListView(); //实例化 Lvl.Left = 0; Lvl.Top = 0; Lvl.Width = this.ClientRectangle.Width; Lvl.Height = this.ClientRectangle.Height; Lvl.GridLines = true;//显示各个记录的分隔线 Lvl.FullRowSelect = true;//要选择就是一行 Lvl.View = View.Details;//定义列表显示的方式 Lvl.Scrollable = true;//需要时候显示滚动条 Lvl.MultiSelect = false; // 不可以多行选择 //listView1.Items.Remove(listView1.SelectedItems[0]); //这样可以在ListView中删除选择的行 Lvl.HeaderStyle = ColumnHeaderStyle.Nonclickable;// 针对数据库的字段名称,建立与之适应显示表头 Lvl.Columns.Add("齿轮", 100, HorizontalAlignment.Right); Lvl.Columns.Add("chi", 100, HorizontalAlignment.Left); Lvl.Columns.Add("C", 100, HorizontalAlignment.Left); Lvl.Visible = true;
C# Dataset在listview中显示问题
C#新手,查询结果放入到Dataset中,不知道哪里出错了,不能在listview显示。 新人写的有点乱,请多多包涵,能给思路和解释最好!![图片说明](https://img-ask.csdn.net/upload/201707/04/1499164356_826919.png)
用C#listview控件Details类型,发现当拉动表头调整列宽度过程时,listview会
用C#listview控件Details类型,发现当拉动表头调整列宽度过程时,listview会重画,造成不停的闪烁.有什么方法让它在宽度调整完后之后,listview才重画
C# listview的循环remove问题
for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--) { ListViewItem item = this.listView1.SelectedItems[i]; this.listView1.Items.Remove(item); } 如上代码可以进行多项删除。 但是我将循环的顺序改成0到count-1后进行删除发现删除的全是奇数项,添加断点查看发现i最后的值为(count-1)/2,代码如下: for (int i = 0; i <= listView1.SelectedItems.Count - 1; i++) { ListViewItem item = this.listView1.SelectedItems[i]; this.listView1.Items.Remove(item); } 本人小白不懂就问
VB+SQL的ListView1不报错,不显示数据
Private Sub ChooseCourse_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim sel1 As String = "select C#,CNAME,CLASSH from C " sel1 = sel1 & "where C# in(select C# from SC " sel1 = sel1 & "where S# = ' " & Login.xuehao & "')" Dim com1 As New SqlCommand(sel1, conn) conn.Open() Dim sreader1 As SqlDataReader = com1.ExecuteReader() Dim item As ListViewItem Dim subitem1, subitem2 As ListViewItem.ListViewSubItem Do While sreader1.Read() item = New ListViewItem(sreader1(0).ToString) subitem1 = New ListViewItem.ListViewSubItem(item, sreader1(1)) item.SubItems.Add(subitem1) subitem2 = New ListViewItem.ListViewSubItem(item, sreader1(2)) item.SubItems.Add(subitem2) ListView1.Items.Add(item) Loop sreader1.Close() conn.Close() End Sub 这是仿照课程信息查询做的,课程信息查询那个窗口显示正常。且SC,C表中有数据,放在SQL查询把Login.xuehao(这个在其他窗口调用正常)换为对应的学号能输出结果。 ![图片说明](https://img-ask.csdn.net/upload/201512/30/1451446723_627030.jpg) ![图片说明](https://img-ask.csdn.net/upload/201512/30/1451446746_565902.jpg) ![图片说明](https://img-ask.csdn.net/upload/201512/30/1451446754_941198.jpg) ![图片说明](https://img-ask.csdn.net/upload/201512/30/1451446765_962789.jpg)
为什么最后一个for语句里的截取字符语句总是出错,大神们帮帮忙啊。。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace TJ { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } public int Pd(string s) { int len = s.Length; //s=str.Substring(str.Length-i); // or str=str.Remove(0,str.Length-i); k = k.Substring(k.Length-1, 1); // string str = s.Substring(s.Length -1,1); //s = s.Remove(s.LastIndexOf(","), 1); /* if (str==","||str==".") { s = s.Remove(s.Length - 2,s.Length -1); }*/ ListViewItem li = new ListViewItem(); for (int i = 0; i < listView1.Items.Count; i++) { if (listView1.Items[i].SubItems[0].Text == s) { return 0; } } return 1; } public int Pdc(string[] sj,string s) { int tem=0; for (int i = 0; i < sj.Length; i++) { if (s == sj[i]) tem++; } return tem; } private void button1_Click(object sender, EventArgs e) { string center = txtDate.Text; string str = center.ToLower(); string[] parm = str.Split(' '); int len = parm.Length; this.listView1.View = View.Details; this.listView1.GridLines = true; this.listView1.HeaderStyle = ColumnHeaderStyle.Nonclickable; this.listView1.Columns.Add("词汇", 120, HorizontalAlignment.Right); this.listView1.Columns.Add("出现次数", 120, HorizontalAlignment.Right); this.listView1.Visible = true; for (int i = 0; i < len; i++) { string s = parm[i]; s = s.Remove(s.LastIndexOf(","), 1); int tem = Pd(parm[i]); if (tem == 1 && parm[i] != "") { int m = Pdc(parm, parm[i]); string mm = Convert.ToString(m); ListViewItem li = new ListViewItem(); li.SubItems[0].Text = parm[i].ToString(); li.SubItems.Add(mm); this.listView1.Items.Add(li); } } } } }
C# ListView 详细信息视图空白
winform 运行程序后Listview有数据,但是切换到详细信息视图就空白了,其他视图全都正常,不知道是什么原因? 数据全都没问题的 链接:https://pan.baidu.com/s/1fR4isB2wspIO7ybBTxSwjw 提取码:lno6 项目我放在了百度, 各位大佬帮我看一下 ``` namespace BookMarksMessages { public partial class Root : Form { public Root() { InitializeComponent(); TreeNode treeNode1 = new TreeNode("根目录"); treeNode1.Text = "根目录"; Directory.Nodes.AddRange(new TreeNode[] { treeNode1}); //BookMarksList.GridLines = true;//显示行与行之间的分隔线 //BookMarksList.FullRowSelect = true;//要选择就是一行 } private void Under_Development_Click(object sender, EventArgs e) { MessageBox.Show("此功能正在开发中...\n敬请期待","开发中...",0); } private void List_Switch(object sender, EventArgs e) { string view = (sender as ToolStripMenuItem).Name.ToString(); this.BookMarksList.View = (View)Enum.Parse(typeof(View), view); } private void ExportToHTML_Click(object sender, EventArgs e) { SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "所有文件(*.*)|*.*|HTML文件(*.html)|*.html"; //保存时为之前的目录 saveFile.RestoreDirectory = true; //保存文件对话框的默认保存类型,默认索引从1开始 saveFile.FilterIndex = 2; if (saveFile.ShowDialog() == DialogResult.OK) { try { FileStream file = new FileStream(saveFile.FileName,FileMode.Create,FileAccess.Write,FileShare.Write); string str = "测试文本"; //字符串转byte[] byte[] bytes = new UTF8Encoding(true).GetBytes(str); //写入字符串 file.Write(bytes, 0, bytes.Length); file.Close(); MessageBox.Show("保存成功!"); } catch (Exception ex) { MessageBox.Show("文件保存错误:\n" + ex); } } } private void ImportFromHTML_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); //设定只能打开HTML文件,文件类型不用加()不然会出错 openFile.Filter = "HTML文件(*.html)|*.html"; //打开时为之前的目录 openFile.RestoreDirectory = true; if (openFile.ShowDialog() == DialogResult.OK) { try { //打开文件,参数列表: 文件名,打开模式,打开权限,其他可以访问此文件的权限 FileStream file = File.Open(openFile.FileName, FileMode.Open, FileAccess.Read, FileShare.Read); //创建读取文件流实例,参数为: 已打开的文件流,编码方式,一般为默认(操作系统当前的编码) StreamReader sr = new StreamReader(file, Encoding.Default); //读取文件并保存到str字符串 string str = sr.ReadToEnd(); HtmlWeb htmlWeb = new HtmlWeb(); HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); //document.Text获取内容 document.LoadHtml(str); //分别用xpath和正则获取内容 //练习 #region 正则 //Regex reg = new Regex("HREF=\"([^\"]+)\""); //MatchCollection result = reg.Matches(document.Text); //string href = ""; //foreach (Match m in result) //{ // reg = new Regex("\".+\""); // Match a = reg.Match(m.ToString()); // href = href + a.ToString() + Environment.NewLine; //} //reg = new Regex("[^\"]+"); //result = reg.Matches(href); //string href1 = ""; //foreach (Match m in result) { // href1 = href1 + m.ToString() + Environment.NewLine; //} #endregion #region xpath HtmlNodeCollection htmlNodes = document.DocumentNode.SelectNodes("//a[@href]"); if (htmlNodes != null) { BookMarksList.Clear(); foreach (HtmlNode n in htmlNodes) { HtmlAttribute hrefAtt = n.Attributes["href"]; ListViewItem item = new ListViewItem(new string[] { n.InnerText.Trim(), hrefAtt.Value }); BookMarksList.Items.Add(item); } } #endregion //关闭读取文件流 sr.Close(); //关闭打开文件流 file.Close(); } catch (Exception ex){//错误处理 MessageBox.Show("文件打开错误:\n"+ex.ToString()); } } } } } ```
终于明白阿里百度这样的大公司,为什么面试经常拿ThreadLocal考验求职者了
点击上面↑「爱开发」关注我们每晚10点,捕获技术思考和创业资源洞察什么是ThreadLocalThreadLocal是一个本地线程副本变量工具类,各个线程都拥有一份线程私有的数
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
此博客仅为我业余记录文章所用,发布到此,仅供网友阅读参考,如有侵权,请通知我,我会删掉。 补充 有不少读者留言说本文章没有用,因为天气预报直接打开手机就可以收到了,为何要多此一举发送到邮箱呢!!!那我在这里只能说:因为你没用,所以你没用!!! 这里主要介绍的是思路,不是天气预报!不是天气预报!!不是天气预报!!!天气预报只是用于举例。请各位不要再刚了!!! 下面是我会用到的两个场景: 每日下
面试官问我:什么是消息队列?什么场景需要他?用了会出现什么问题?
你知道的越多,你不知道的越多 点赞再看,养成习惯 GitHub上已经开源 https://github.com/JavaFamily 有一线大厂面试点脑图、个人联系方式,欢迎Star和完善 前言 消息队列在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在消息队列的使用和原理方面对小伙伴们进行360°的刁难。 作为一个在互联网公司面一次拿一次Offer的面霸,打败了无数
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观
程序员一般通过什么途径接私活?
二哥,你好,我想知道一般程序猿都如何接私活,我也想接,能告诉我一些方法吗? 上面是一个读者“烦不烦”问我的一个问题。其实不止是“烦不烦”,还有很多读者问过我类似这样的问题。 我接的私活不算多,挣到的钱也没有多少,加起来不到 20W。说实话,这个数目说出来我是有点心虚的,毕竟太少了,大家轻喷。但我想,恰好配得上“一般程序员”这个称号啊。毕竟苍蝇再小也是肉,我也算是有经验的人了。 唾弃接私活、做外
大学四年自学走来,这些珍藏的「实用工具/学习网站」我全贡献出来了
知乎高赞:文中列举了互联网一线大厂程序员都在用的工具集合,涉及面非常广,小白和老手都可以进来看看,或许有新收获。
《阿里巴巴开发手册》读书笔记-编程规约
Java编程规约命名风格 命名风格 类名使用UpperCamelCase风格 方法名,参数名,成员变量,局部变量都统一使用lowerCamelcase风格 常量命名全部大写,单词间用下划线隔开, 力求语义表达完整清楚,不要嫌名字长 ...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
你知道的越多,你不知道的越多 点赞再看,养成习惯 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试点思维导图,也整理了很多我的文档,欢迎Star和完善,大家面试可以参照考点复习,希望我们一起有点东西。 前前言 为啥今天有个前前言呢? 因为你们的丙丙啊,昨天有牌面了哟,直接被微信官方推荐,知乎推荐,也就仅仅是还行吧(心里乐开花)
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca
Python爬虫精简步骤1 获取数据
爬虫的工作分为四步: 1.获取数据。爬虫程序会根据我们提供的网址,向服务器发起请求,然后返回数据。 2.解析数据。爬虫程序会把服务器返回的数据解析成我们能读懂的格式。 3.提取数据。爬虫程序再从中提取出我们需要的数据。 4.储存数据。爬虫程序把这些有用的数据保存起来,便于你日后的使用和分析。 这一篇的内容就是:获取数据。 首先,我们将会利用一个强大的库——requests来获取数据。 在电脑上安装
Python绘图,圣诞树,花,爱心 | Turtle篇
1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle() circle.shape('circle') circle.color('red') circle.speed('fastest') circle.up() square = turtle.Turtle()
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 更多有趣分析教程,扫描下方二维码关注vx公号「裸睡的猪」 即可查看! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布
听说想当黑客的都玩过这个Monyer游戏(1~14攻略)
第零关 进入传送门开始第0关(游戏链接) 请点击链接进入第1关: 连接在左边→ ←连接在右边 看不到啊。。。。(只能看到一堆大佬做完的留名,也能看到菜鸡的我,在后面~~) 直接fn+f12吧 &lt;span&gt;连接在左边→&lt;/span&gt; &lt;a href="first.php"&gt;&lt;/a&gt; &lt;span&gt;←连接在右边&lt;/span&gt; o
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ......
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
别低估自己的直觉,也别高估自己的智商
所有群全部吵翻天,朋友圈全部沦陷,公众号疯狂转发。这两周没怎么发原创,只发新闻,可能有人注意到了。我不是懒,是文章写了却没发,因为大家的关注力始终在这次的疫情上面,发了也没人看。当然,我...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。   再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。   下文是原回答,希望能对你能有所启发。   如果我说,这个世界上人真的分三六九等,
为什么听过很多道理,依然过不好这一生?
记录学习笔记是一个重要的习惯,不希望学习过的东西成为过眼云烟。做总结的同时也是一次复盘思考的过程。 本文是根据阅读得到 App上《万维钢·精英日课》部分文章后所做的一点笔记和思考。学习是一个系统的过程,思维模型的建立需要相对完整的学习和思考过程。以下观点是在碎片化阅读后总结的一点心得总结。
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合
如何优雅地打印一个Java对象?
你好呀,我是沉默王二,一个和黄家驹一样身高,和刘德华一样颜值的程序员。虽然已经写了十多年的 Java 代码,但仍然觉得自己是个菜鸟(请允许我惭愧一下)。 在一个月黑风高的夜晚,我思前想后,觉得再也不能这么蹉跎下去了。于是痛下决心,准备通过输出的方式倒逼输入,以此来修炼自己的内功,从而进阶成为一名真正意义上的大神。与此同时,希望这些文章能够帮助到更多的读者,让大家在学习的路上不再寂寞、空虚和冷。 ...
雷火神山直播超两亿,Web播放器事件监听是怎么实现的?
Web播放器解决了在手机浏览器和PC浏览器上播放音视频数据的问题,让视音频内容可以不依赖用户安装App,就能进行播放以及在社交平台进行传播。在视频业务大数据平台中,播放数据的统计分析非常重要,所以Web播放器在使用过程中,需要对其内部的数据进行收集并上报至服务端,此时,就需要对发生在其内部的一些播放行为进行事件监听。 那么Web播放器事件监听是怎么实现的呢? 01 监听事件明细表 名
3万字总结,Mysql优化之精髓
本文知识点较多,篇幅较长,请耐心学习 MySQL已经成为时下关系型数据库产品的中坚力量,备受互联网大厂的青睐,出门面试想进BAT,想拿高工资,不会点MySQL优化知识,拿offer的成功率会大大下降。 为什么要优化 系统的吞吐量瓶颈往往出现在数据库的访问速度上 随着应用程序的运行,数据库的中的数据会越来越多,处理时间会相应变慢 数据是存放在磁盘上的,读写速度无法和内存相比 如何优化 设计
Linux 命令(122)—— watch 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] watch(1) manual
Linux 命令(121)—— cal 命令
1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 [1] cal(1) manual
记jsp+servlet+jdbc实现的新闻管理系统
1.工具:eclipse+SQLyog 2.介绍:实现的内容就是显示新闻的基本信息,然后一个增删改查的操作。 3.数据库表设计 列名 中文名称 数据类型 长度 非空 newsId 文章ID int 11 √ newsTitle 文章标题 varchar 20 √ newsContent 文章内容 text newsStatus 是否审核 varchar 10 news...
Python新型冠状病毒疫情数据自动爬取+统计+发送报告+数据屏幕(三)发送篇
今天介绍的项目是使用 Itchat 发送统计报告 项目功能设计: 定时爬取疫情数据存入Mysql 进行数据分析制作疫情报告 使用itchat给亲人朋友发送分析报告(本文) 基于Django做数据屏幕 使用Tableau做数据分析 来看看最终效果 目前已经完成,预计2月12日前更新 使用 itchat 发送数据统计报告 itchat 是一个基于 web微信的一个框架,但微信官方并不允
相关热词 c# 时间比天数 c# oracle查询 c# 主动推送 事件 c# java 属性 c# 控制台 窗体 c# 静态类存值 c#矢量作图 c#窗体调用外部程式 c# enum是否合法 c# 如何卸载引用
立即提问