473,795 Members | 2,968 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting the length of datagrid columns

bob
I am binding a datatable to a datagrid in VB.NET I then want to change
the width of the first column. I am unable to get the right syntax.

Here is the code I tried
Dim mydataset As DataSet

gclodatabase.Ge tDataSetJobs("S elect * from qryJobs",
mydataset)
Dim Mydatatable As DataTable = mydataset.Table s(0)
dtgSelect.DataS ource = mydataset.Table s(0)

dtgSelect.Table Styles(0).GridC olumnStyles("Jo bId").Width = 10

‘ this fails with an error An unhandled exception of type
'System.NullRef erenceException ' occurred in Proposals.exe

‘Additional information: Object reference not set to an instance of an
‘object.
dtgSelect.Table Styles(0).GridC olumnStyles(1). Width = 10

‘ this fails with error

‘An unhandled exception of type 'System.Argumen tOutOfRangeExce ption'
‘occurred in mscorlib.dll

‘Additional information: Index was out of range. Must be non-negative
‘and less than the size of the collection.
dtgSelect.Refre sh()
Nov 20 '05 #1
2 1589
Hi
You need to add the TableStyle "JobID" to the datagrid
before you can use it.
Kind Regards
Jorge
-----Original Message-----
I am binding a datatable to a datagrid in VB.NET I then want to changethe width of the first column. I am unable to get the right syntax.
Here is the code I tried
Dim mydataset As DataSet

gclodatabase.Ge tDataSetJobs("S elect * from qryJobs",mydataset)
Dim Mydatatable As DataTable = mydataset.Table s (0)

dtgSelect.DataS ource = mydataset.Table s(0)

dtgSelect.Table Styles(0).GridC olumnStyles ("JobId").Wi dth = 10
' this fails with an error An unhandled exception of type
'System.NullRe ferenceExceptio n' occurred in Proposals.exe

'Additional information: Object reference not set to an instance of an'object.
dtgSelect.Table Styles(0).GridC olumnStyles (1).Width = 10
' this fails with error

'An unhandled exception of type 'System.Argumen tOutOfRangeExce ption''occurred in mscorlib.dll

'Additional information: Index was out of range. Must be non-negative'and less than the size of the collection.
dtgSelect.Refre sh()
.

Nov 20 '05 #2
>>
Hi
You need to add the TableStyle "JobID" to the datagrid
before you can use it.
Kind Regards
Jorge


Can you show me what the line of code is to do that?

Thanks,

Bob Avallone
www.metaprosystems.com


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

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

Similar topics

8
2842
by: Nevyn Twyll | last post by:
I have a multi-level datalist setup: DataList1 DataList2 MyGrid I have columns explicitly defined for the grid in the html. Sometimes, On the initial Load() of the Page, I want to add extra columns to the datagrid - for all records. I tried getting a reference to the datagrid like this:
5
3510
by: Brian Henry | last post by:
I have a messaging application that has a data grid with information like an email list would have (from, subject, time sent, size) but the subject could be very long in theory, and then it would word wrap.. the subject is a variable width column (resizes to fit space) while the others are fixed size... the problem is that i dont want the text to ever word wrap.. but truncate the visible subject to match the current cell width... (kinda...
2
2686
by: Ron L | last post by:
I am attempting to set up a datagrid that will 1) display a subset of data from a SQL Stored Procedure in a different order form how SQL returns it, and 2) display 3 of the columns using pulldowns. I have gotten code for both from the www.syncfusion.com site, but am having trouble making them work. Below is the relevant code: ' Setup the permissions grid ' Fill the dataset of permissions Dim dt As DataTable = dsUserData.Tables(0)
8
3929
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some addition fields. I'm able to get the datagrid to be properly populate with only the child records relating to the specified parent by setting the ..DefaultView.RowFilter property. Currently, to properly add a new child record, I need to manually...
6
7108
by: cr113 | last post by:
I'm trying to set the column widths for a datagrid. You'd think it would be easy. I looked it up in google and the first thing I found looked promising: datagrid1.columns(0).width = 2000 datagrid1.columns(1).width = 1000 Except that there is no such things as a columns collection in a datagrid.
4
4194
by: Rich | last post by:
Hello, I have a one datagrid that will be based on different datatables. One datatable may have 7 columns, another 15... With the tables that have more columns, I have been manually dragging column widths to narrow them. I want to record these widths so I can reapply them when I bind the datagrid to the table with 15 columns. I have searched around for articles on this and saw some that talked about...
2
10406
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat actually happens is... when the Text size is too big... the column
1
6510
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
0
1229
by: Rocky | last post by:
Dear ALL, I am facing a bit problem in DATAGRID. so may be you guys can help me out. Actually on a DataGrid I am having following controls: 1) 2 DropDown Menu 2) 1 Text Box 3) 1 ADD Button 4) 1 Remove Button So these all controls are in 1 row and looks like:
0
9519
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,...
1
10165
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
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9043
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
7541
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
6783
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
5437
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...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.