473,782 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid column width won't change

Ben
Could someone please tell me why couldn't I adjust my column/row properties
of my dataGrid? I binded my table, created a new DataGridTableSt yle and
mapped it to my datagrid. However, my columns width wouldn't changed at all.
I am sure this is very easy thing to figure out but I just couldn't see it.
Could you please take a look at my codes. What I am missing? Btw, I got
these codes from MSDN website:

thanks.

.....
Private myDataGrid As DataGrid
Private myDataSet As DataSet
Private TablesAlreadyAd ded As Boolean
Private ts1 As New DataGridTableSt yle
....

from my default constructor, I rand SetUp()
......
Private Sub SetUp()
'create a dataset with two tables and one relation.
MakeDataSet()
'bind the datagrid to the dataset. the datamember
'specifies that the customers table should be displayed.
myDataGrid.SetD ataBinding(myDa taSet, "customers" )

Dim ts1 As New DataGridTableSt yle
ts1.MappingName = "customers"
Dim myDataCol As New DataGridBoolCol umn
myDataCol.Heade rText = "My New Column"
myDataCol.Mappi ngName = "current"
myDataCol.Width = 4000000
ts1.GridColumnS tyles.Add(myDat aCol)
myDataGrid.Tabl eStyles.Add(ts1 )

End Sub
............... ......along that path, it should execute this dataset then
bind to myDataGrid
Private Sub MakeDataSet()
myDataSet = New DataSet("myData Set")

Dim tCust As New DataTable("Cust omers")
Dim cRecordName As New DataColumn("Rec ord Name", GetType(Integer ))
Dim cUnitOfMeasurem ent As New DataColumn("Uni t Of Measurement")
Dim cSimulationCase No As New DataColumn("Sim ulation Case Number")
tCust.Columns.A dd(cRecordName)
tCust.Columns.A dd(cUnitOfMeasu rement)
tCust.Columns.A dd(cSimulationC aseNo)

myDataSet .Tables.Add(tCu st)

Dim newRow1 As DataRow

Dim i As Integer
For i = 1 To 3
newRow1 = tCust.NewRow()
newRow1("Record Name") = i
tCust.Rows.Add( newRow1)
Next i
tCust.Rows(0)(" Unit Of Measurement") = "Customer1"
tCust.Rows(1)(" Unit Of Measurement") = "Customer2"
tCust.Rows(2)(" Unit Of Measurement") = "Customer3"

tCust.Rows(0)(" Simulation Case Number") = "asdf"
tCust.Rows(1)(" Simulation Case Number") = "asdf"
tCust.Rows(2)(" Simulation Case Number") = "asdfdas"
End Sub
Nov 21 '05 #1
2 1843
Hi,

The mappingname for the tablestyle is case sensitive. Try
using Customers instead of customers. Not sure if the datagrid supports
column widths of 4000000

Ken
--------------------
"Ben" <Be*@discussion s.microsoft.com > wrote in message
news:2A******** *************** ***********@mic rosoft.com...
Could someone please tell me why couldn't I adjust my column/row properties
of my dataGrid? I binded my table, created a new DataGridTableSt yle and
mapped it to my datagrid. However, my columns width wouldn't changed at
all.
I am sure this is very easy thing to figure out but I just couldn't see it.
Could you please take a look at my codes. What I am missing? Btw, I got
these codes from MSDN website:

thanks.

.....
Private myDataGrid As DataGrid
Private myDataSet As DataSet
Private TablesAlreadyAd ded As Boolean
Private ts1 As New DataGridTableSt yle
....

from my default constructor, I rand SetUp()
......
Private Sub SetUp()
'create a dataset with two tables and one relation.
MakeDataSet()
'bind the datagrid to the dataset. the datamember
'specifies that the customers table should be displayed.
myDataGrid.SetD ataBinding(myDa taSet, "customers" )

Dim ts1 As New DataGridTableSt yle
ts1.MappingName = "customers"
Dim myDataCol As New DataGridBoolCol umn
myDataCol.Heade rText = "My New Column"
myDataCol.Mappi ngName = "current"
myDataCol.Width = 4000000
ts1.GridColumnS tyles.Add(myDat aCol)
myDataGrid.Tabl eStyles.Add(ts1 )

End Sub
............... ......along that path, it should execute this dataset then
bind to myDataGrid
Private Sub MakeDataSet()
myDataSet = New DataSet("myData Set")

Dim tCust As New DataTable("Cust omers")
Dim cRecordName As New DataColumn("Rec ord Name", GetType(Integer ))
Dim cUnitOfMeasurem ent As New DataColumn("Uni t Of Measurement")
Dim cSimulationCase No As New DataColumn("Sim ulation Case Number")
tCust.Columns.A dd(cRecordName)
tCust.Columns.A dd(cUnitOfMeasu rement)
tCust.Columns.A dd(cSimulationC aseNo)

myDataSet .Tables.Add(tCu st)

Dim newRow1 As DataRow

Dim i As Integer
For i = 1 To 3
newRow1 = tCust.NewRow()
newRow1("Record Name") = i
tCust.Rows.Add( newRow1)
Next i
tCust.Rows(0)(" Unit Of Measurement") = "Customer1"
tCust.Rows(1)(" Unit Of Measurement") = "Customer2"
tCust.Rows(2)(" Unit Of Measurement") = "Customer3"

tCust.Rows(0)(" Simulation Case Number") = "asdf"
tCust.Rows(1)(" Simulation Case Number") = "asdf"
tCust.Rows(2)(" Simulation Case Number") = "asdfdas"
End Sub
Nov 21 '05 #2
Ben,

Mostly these errors come if you don't use the same cases as you do in your
code
This part is with windowsforms programming case sensitive (rarely it is not
with a webform datagrid).

I hope this helps,

Cor
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
366
by: Eva | last post by:
How do i indivually change the width of a datagrid coloumn? I am currently using the PrefferedColoumnWidth property, but due to space restrictions i do not want all the columns at the same width. Any help is appreciated.
5
3380
by: Prateek | last post by:
Hi, How can I change the width of a column in datagrid control? TIA Prateek
1
1554
by: Tim Wallace | last post by:
I have a .NET 1.1, C# desktop application. In this app, there is a window wherein I use the DataGrid control to display info for the user to edit. I then grab that data (which initially comes from an accumulator table) and call a stored procedure that places this data in a different table. Everything works fine, save for a cosmetic issue. One of my columns needs to be wider than the others to display more intelligble data. I cannot...
1
11627
by: | last post by:
How do I change the datagrid column width dynamically when the grid's being loaded? VM
3
31124
by: frank | last post by:
How do I set the column width of a column in a DataGrid programatically (in ASP.NET web pages)? I understand I may have to use DataGridTableStyle, but I can't get this to work with web pages. Any help would be appreciated.
24
10766
by: Mike L | last post by:
This is for a Win form, in C# 2005. I want to load a datagrid, make some columns width 0, and then clean out the record I added. I get the error message, ""Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"" I have tried, -1,0,1,2 for the index, and I get the same error message on each try.
1
3191
by: salih ataoz | last post by:
i have a form1 and i put Datagrid1 on it and i want to change its column width and row hight ex: datagrid1.column(0).width=200 datagrid1.row(0).width=100 or datagrid1.allcolumnwidth=200
3
1548
by: Sean | last post by:
How do I change the width of a Datagrid column programatically to make it look better when displayed (no gray area after columns). Thanks
3
4685
by: Aziz | last post by:
1. I have a shopping basket DataGrid with a list of products. What I want to do is when the user clicks on a row, a button will become visible/be created that allows user to edit the quantity. The button will be dynamic and always show up on the same Y-axis position as the selected row. So, how do I get back the X, Y co-ordinates of a specific row in a datagrid relative to the form? 2. I managed to change individual column width using:
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.