Click here to Skip to main content
15,905,616 members
Home / Discussions / C#
   

C#

 
GeneralRe: dll question Pin
Heath Stewart10-Jul-03 9:00
protectorHeath Stewart10-Jul-03 9:00 
QuestionHow to Set Widths of Columns in a DataGrid, Anyone? Pin
Khang Nguyen10-Jul-03 6:17
Khang Nguyen10-Jul-03 6:17 
AnswerRe: How to Set Widths of Columns in a DataGrid, Anyone? Pin
Heath Stewart10-Jul-03 9:11
protectorHeath Stewart10-Jul-03 9:11 
Use DataGridTableStyles. You can easily do this during design-time with the DataGrid.TableStyles property. You can have multiple table styles, each bound to a different DataMember name (usually tables of a DataSet or something). Within each of these table styles, you specify each column and bind them to a DataColumn name (for each row of the table to which the style is bound). Programmatically, the same procedure is used. Lets say you want the last column of the first table style to be 100 pixels:
int count = dataGrid1.TableStyles[0].GridColumnStyles.Count;
dataGrid1.TableStyles[0].GridColumnStyles[count - 1].Width = 100;


This is for a System.Windows.Forms.DataGrid and can use other data sources other than a DataSet since table styles themselves don't have to bind to any data member and you can just specify the grid columns bound to certain columns / properties in whatever data source you use.

Now, if this is a System.Web.UI.WebControls.DataGrid, you have to use template styles.

In either case, try it in the visual designer, look at the code produced in the source file, and read the docs so you understand exactly what you're reading. It's not that hard and you can customize a lot without overriding anything.

 

Reminiscent of my younger years...
10 LOAD "SCISSORS"
20 RUN

GeneralRe: How to Set Widths of Columns in a DataGrid, Anyone? Pin
Khang Nguyen10-Jul-03 11:50
Khang Nguyen10-Jul-03 11:50 
GeneralExport Unmanaged DLL's classes instead of just function using PInvoke Pin
Anonymous10-Jul-03 5:40
Anonymous10-Jul-03 5:40 
GeneralRe: Export Unmanaged DLL's classes instead of just function using PInvoke Pin
leppie10-Jul-03 7:10
leppie10-Jul-03 7:10 
GeneralRe: Export Unmanaged DLL's classes instead of just function using PInvoke Pin
Anonymous10-Jul-03 7:36
Anonymous10-Jul-03 7:36 
GeneralRe: Export Unmanaged DLL's classes instead of just function using PInvoke Pin
leppie10-Jul-03 11:24
leppie10-Jul-03 11:24 
GeneralError Reading from MDB System Table Pin
SD310-Jul-03 5:17
SD310-Jul-03 5:17 
QuestionWhy DataSet Not Updated, Any Gurus? Pin
Khang Nguyen10-Jul-03 5:14
Khang Nguyen10-Jul-03 5:14 
AnswerRe: Why DataSet Not Updated, Any Gurus? Pin
Heath Stewart10-Jul-03 9:14
protectorHeath Stewart10-Jul-03 9:14 
GeneralRe: Why DataSet Not Updated, Any Gurus? Pin
Khang Nguyen10-Jul-03 11:54
Khang Nguyen10-Jul-03 11:54 
GeneralC#, Java and memory Pin
albean10-Jul-03 4:52
albean10-Jul-03 4:52 
GeneralRe: C#, Java and memory Pin
Ylis10-Jul-03 5:01
Ylis10-Jul-03 5:01 
GeneralRe: C#, Java and memory Pin
KingTermite11-Jul-03 7:44
KingTermite11-Jul-03 7:44 
Generalaccessing the key buffer Pin
Ylis10-Jul-03 4:51
Ylis10-Jul-03 4:51 
GeneralRe: accessing the key buffer Pin
Heath Stewart10-Jul-03 11:00
protectorHeath Stewart10-Jul-03 11:00 
GeneralRe: accessing the key buffer Pin
Ylis11-Jul-03 12:51
Ylis11-Jul-03 12:51 
GeneralWindows Application Startup Pin
bcox10-Jul-03 4:34
bcox10-Jul-03 4:34 
GeneralCombo Box Pin
totig10-Jul-03 4:23
totig10-Jul-03 4:23 
GeneralDisplay a form in a windows service Pin
Anonymous9-Jul-03 23:38
Anonymous9-Jul-03 23:38 
GeneralWebservice error: underlying connection was closed Pin
BigAndy9-Jul-03 22:39
BigAndy9-Jul-03 22:39 
GeneralRe: Webservice error: underlying connection was closed Pin
Kannan Kalyanaraman10-Jul-03 0:40
Kannan Kalyanaraman10-Jul-03 0:40 
GeneralContextMenu & TextBox Pin
almigrp9-Jul-03 20:27
almigrp9-Jul-03 20:27 
GeneralRe: ContextMenu & TextBox Pin
Heath Stewart10-Jul-03 3:32
protectorHeath Stewart10-Jul-03 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.