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

推荐订阅源

M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
S
Schneier on Security
aimingoo的专栏
aimingoo的专栏
T
Troy Hunt's Blog
U
Unit 42
Hacker News - Newest:
Hacker News - Newest: "LLM"
V2EX - 技术
V2EX - 技术
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
H
Heimdal Security Blog
H
Hacker News: Front Page
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Cloudbric
Cloudbric
Google DeepMind News
Google DeepMind News
C
Cisco Blogs
The Cloudflare Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
N
News | PayPal Newsroom
Attack and Defense Labs
Attack and Defense Labs
D
DataBreaches.Net
N
News and Events Feed by Topic
Security Archives - TechRepublic
Security Archives - TechRepublic
Forbes - Security
Forbes - Security
Simon Willison's Weblog
Simon Willison's Weblog
F
Full Disclosure
The Register - Security
The Register - Security
L
LINUX DO - 热门话题
Webroot Blog
Webroot Blog
Google Online Security Blog
Google Online Security Blog
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
Intezer
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
K
Kaspersky official blog
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
T
Threatpost
Spread Privacy
Spread Privacy
小众软件
小众软件
AWS News Blog
AWS News Blog
S
Secure Thoughts
S
Security @ Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks

博客园 - 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
     }
 
}