本文介绍了如何在窗口应用程序的C#中修复(不拉伸)DataGridView列.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从数据库(sql server)中获取了一些记录,但是列被拉伸了.现在,我要修复没有人可以拉伸的列.

如何在窗口应用程序的C#中修复(不拉伸)DataGridView列.
所以告诉我正确的答案.

我的代码是---

I have fetched some records from the database(sql server) but the columns are stretched . Now I want to fix the column that nobody can stretch it.

How to fix(no stretch) the DataGridView column in C# in window application.
So tell me the right answer.

My code is---

string connectionString = ConfigurationSettings.AppSettings["cnn"];
string selectSQL = "SELECT last,first FROM contactmngt where last Like 's%' ";
SqlDataAdapter adp = new SqlDataAdapter(selectSQL, cnn);
SqlCommandBuilder cmd = new SqlCommandBuilder(adp);
DataTable dtusers = new DataTable();
adp.Fill(dtusers);
            
          
dataGridView1.DataSource = dtusers;
dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
dataGridView1.Columns["last"].Frozen= true;
dataGridView1.Columns["first"].Frozen = true;




添加了"pre"标签




added "pre" tags

推荐答案

dataGridView1.AllowUserToResizeColumns = false;


这篇关于如何在窗口应用程序的C#中修复(不拉伸)DataGridView列.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 01:42