|
-
Mar 17th, 2004, 08:50 AM
#1
Thread Starter
Member
DataGrid control problem
Hi all,
I am trying to create a form that will allow a user to enter values against items for each day of the week.
I am looking at the Datagrid control to do this, using a DataTable as it's source.
My problems are that I cannot work out how I can customize the DataGrid's colmn widths. The Item width needs to be large, but the values small. Is this possible?
Secondly, how do I prevent the end-user from adding records - I do not want them too, but there is always a new record line at the bottom of the data grid.
In fact, if anyone can suggest a control better suited for doing this I'd be most interested.
Many Thanks.
-
Mar 17th, 2004, 04:06 PM
#2
Junior Member
if you want to go with the datagrid you can use a "datagridTableStyle" like this..
Code:
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "TableName"
Dim column As New DataGridTextBoxColumn
column.MappingName = "Productname"
column.HeaderText = "Productname"
column.Width = 200
column.ReadOnly() = True
tableStyle.GridColumnStyles.Add(column)
Dim AnswerCol As New DataGridTextBoxColumn
AnswerCol.MappingName = "Yes"
AnswerCol.HeaderText = "Yes"
AnswerCol.Width = 30
AnswerCol.AllowNull = False
tableStyle.GridColumnStyles.Add(AnswerCol)
AnswerCol = New DataGridTextBoxColumn
AnswerCol.MappingName = "No"
AnswerCol.HeaderText = "No"
AnswerCol.Width = 30
AnswerCol.AllowNull = False
tableStyle.GridColumnStyles.Add(AnswerCol)
AnswerCol = New DataGridTextBoxColumn
AnswerCol.MappingName = "Error"
AnswerCol.HeaderText = "Error"
AnswerCol.Width = 30
AnswerCol.AllowNull = False
tableStyle.GridColumnStyles.Add(AnswerCol)
Me.MyDataGrid.TableStyles.Add(tableStyle)
to turn off the extra line at the bottom just make the datagrid ReadOnly. Then you can set in the "datagridTableStyle" column.ReadOnly() = False
An example of how to customize a datagrid is found at:
Custom Datagrid
-
Mar 17th, 2004, 06:04 PM
#3
Thread Starter
Member
-
Mar 18th, 2004, 09:32 AM
#4
Thread Starter
Member
Well I have got a lot further now, however I'm still unable to get rid of the auto 'new row' line at the bottom of the grid (this being fixed data in which the user must not add a new row).
Making the datagrid readonly - prevents this new row line from appearing, but also overrides all the colmns so they are all read-only as well (despite .Readonly = False on the columns) - thus the user cannot change any data either, which is not what i want!
I will also be needed a total columen and row for this which will no doubt prove tricky to impossible!
Any further advice much appreciated, Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|