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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - Box

ASP.NET 配置文件层次结构和继承(转) NetAdvantage 2007 CLR1x ASPNET 注册码 SN - Box 处理SPS错误:只有在配置文件或 Page 指令中将启用会话状态设置为真时,才可以使用会话状态 - Box C# 处理xml(转) 关于版权声明的写法(转) 编写优秀技术文档的技巧(转) - Box 教你怎样做项目开发总结报告(转) 如何编写高质量软件需求说明书(转) 如何编写企业解决方案书(转) 如何编写高质量的需求(转) - Box 如何写好测试报告(转) 如何写系统分析书(转) Macromedia Captivate 使用手册(转) - Box 改变你一生的五句话 (转) Windows 使用FTP批处理脚本(转) - Box professional C# 2005 下载地址 - Box Windows 安装组件注意事项 - Box 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
     }
 
}