Having populated my datagrid with the following code,
DA = New SqlCeDataAdapter(SqlceCmd)
MyData = New DataTable
DA.Fill(MyData)
MyData.Columns(0).ColumnName = "Task"
MyData.Columns(1).ColumnName = "Reported"
IncidentDtl.DataSource = MyData
IncidentDtl.Refresh()
I now want to change the size of the columns. Could someone please let me know how to manipulate the appearance of my grid as my grid IncidentDtl doesn't seem to have a Columns property only the Table does.
I would take this thread to one of the Visual Studio or Visual Basic (or even C#) forums. Many of these SQL Server folks don't have much experience with the inner workings of the DataGridView control.
The DataGridView has any number of properties like the AutoSizeColumnsMode that can automatically set the size of the columns based on the first row width, the displayed rows maximum width etc.
|||What about:
Code Snippet
DataGridView dgw = new DataGridView();
dgw.Columns["SomeColumn"].Width = 100;
Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||Ah, that would be nice, but the Columns collection.Width property is read-only.
|||http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.width.aspxDataGridViewColumn.Width Property
Gets or sets the current width of the column.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Jens K. Suessmeyer
http://www.sqlserver2005.de