我使用 Visual Studio 的 SQL Server Compact 3.5 创建了一个数据库和表,并将数据集作为我的数据源。在我的 WinForm 上,我有一个包含 3 列的 DataGridView。但是,我一直无法弄清楚如何让列占据 DataGridView 的整个宽度,如下图所示。
我想让缩写列更宽,然后让描述列一直延伸到表单的边缘。有什么建议么?
更新:
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 QuickNote
{
public partial class hyperTextForm : Form
{
private static hyperTextForm instance;
public hyperTextForm()
{
InitializeComponent();
this.WindowState = FormWindowState.Normal;
this.MdiParent = Application.OpenForms.OfType<Form1>().First();
}
public static hyperTextForm GetInstance()
{
if (instance == null || instance.IsDisposed)
{
instance = new hyperTextForm();
}
return instance;
}
private void abbreviationsBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.abbreviationsBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.keywordDBDataSet);
}
private void hyperTextForm_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'keywordDBDataSet.abbreviations' table. You can move, or remove it, as needed.
this.abbreviationsTableAdapter.Fill(this.keywordDBDataSet.abbreviations);
abbreviationsDataGridView.Columns[1].Width = 60;
abbreviationsDataGridView.Columns[2].Width = abbreviationsDataGridView.Width - abbreviationsDataGridView.Columns[0].Width - abbreviationsDataGridView.Columns[1].Width - 72;
}
}
}