惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Heimdal Security Blog
A
Arctic Wolf
K
Kaspersky official blog
V
Vulnerabilities – Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 热门话题
MongoDB | Blog
MongoDB | Blog
T
Threat Research - Cisco Blogs
D
Docker
爱范儿
爱范儿
T
Tenable Blog
C
Check Point Blog
B
Blog
C
Cisco Blogs
Vercel News
Vercel News
The Cloudflare Blog
T
Threatpost
NISL@THU
NISL@THU
T
Tor Project blog
V2EX - 技术
V2EX - 技术
P
Palo Alto Networks Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tailwind CSS Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
SecWiki News
SecWiki News
博客园 - 司徒正美
S
Security @ Cisco Blogs
GbyAI
GbyAI
S
Secure Thoughts
Microsoft Security Blog
Microsoft Security Blog
The Register - Security
The Register - Security
Recorded Future
Recorded Future
Cloudbric
Cloudbric
Webroot Blog
Webroot Blog
N
News and Events Feed by Topic
Y
Y Combinator Blog
博客园_首页
T
Troy Hunt's Blog
The Hacker News
The Hacker News
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
U
Unit 42
AWS News Blog
AWS News Blog
PCI Perspectives
PCI Perspectives
V
Visual Studio Blog
博客园 - 聂微东
有赞技术团队
有赞技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - Box

ASP.NET 配置文件层次结构和继承(转) NetAdvantage 2007 CLR1x ASPNET 注册码 SN 处理SPS错误:只有在配置文件或 Page 指令中将启用会话状态设置为真时,才可以使用会话状态 - Box C# 处理xml(转) 关于版权声明的写法(转) 编写优秀技术文档的技巧(转) 教你怎样做项目开发总结报告(转) 如何编写高质量软件需求说明书(转) 如何编写企业解决方案书(转) 如何编写高质量的需求(转) 如何写好测试报告(转) 如何写系统分析书(转) Macromedia Captivate 使用手册(转) 改变你一生的五句话 (转) Windows 使用FTP批处理脚本(转) professional C# 2005 下载地址 Windows 安装组件注意事项 SQLServer数据库完整迁移(转) 计算字段.
让DataGridView 带*号的一行不显示!
Box · 2006-12-08 · via 博客园 - Box

How do I prevent the datagrid from displaying its append row (the row at the end with an asterisk)?
原文:http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q653q

The DataGrid class does not have a property that controls whether a new row can be added. But the DataView class does have such a property (along with some others such as AllowEdit and AllowDelete). Here is code that will turn off the append row by getting at the dataview associated with the datagrid.

     string connString = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb"
     
string sqlString = "SELECT * FROM customers"
 
         
// Connection object 
     OleDbConnection connection = new OleDbConnection(connString); 
  
     
// Create data adapter object 
     OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sqlString, connection); 
  
     
// Create a dataset object and fill with data using data adapter's Fill method 
     DataSet dataSet = new DataSet(); 
     dataAdapter.Fill(dataSet, 
"customers"); 
  
     
// Attach dataset's DefaultView to the datagrid control 
    dataGrid1.DataSource = dataSet.Tables["customers"]; 
     
//no adding of new rows thru dataview 
     CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];      
     ((DataView)cm.List).AllowNew 
= false;

If your datagrid contains links, then Matthew Miller suggest adding Navigate handler such as the one below to disallow the AddNew.

private void DataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne) 

     
if(ne.Forward) 
     

          CurrencyManager cm 
= (CurrencyManager)BindingContext[DataGrid1.DataSource,DataGrid1.DataMember]; 
          DataView dv 
= (DataView) cm.List; 
          dv.AllowNew 
= false
     }
 
}