I have created a database and table using Visual Studio's SQL Server Compact 3.5 with a dataset as my datasource. On my WinForm I have a DataGridView with 3 columns. However, I have been unable to figure out how to get the columns to take up the full width of the DataGridView which is shown in the image below.
I want to make the abbreviates column wider and then have the description column extend all the way over to the edge of the form. Any suggestions?
Update:
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;
}
}
}
I have created a database and table using Visual Studio's SQL Server Compact 3.5 with a dataset as my datasource. On my WinForm I have a DataGridView with 3 columns. However, I have been unable to figure out how to get the columns to take up the full width of the DataGridView which is shown in the image below.
I want to make the abbreviates column wider and then have the description column extend all the way over to the edge of the form. Any suggestions?
Update:
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;
}
}
}
I have created a database and table using Visual Studio's SQL Server Compact 3.5 with a dataset as my datasource. On my WinForm I have a DataGridView with 3 columns. However, I have been unable to figure out how to get the columns to take up the full width of the DataGridView which is shown in the image below.
I want to make the abbreviates column wider and then have the description column extend all the way over to the edge of the form. Any suggestions?
Update:
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;
}
}
}
I have created a database and table using Visual Studio's SQL Server Compact 3.5 with a dataset as my datasource. On my WinForm I have a DataGridView with 3 columns. However, I have been unable to figure out how to get the columns to take up the full width of the DataGridView which is shown in the image below.
I want to make the abbreviates column wider and then have the description column extend all the way over to the edge of the form. Any suggestions?
Update:
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;
}
}
}
我已经阅读了您的解决方案,但我不知道在哪里写它们,因为我有Form1.cs 、 Program.cs和From1.Designer.cs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.