473,511 Members | 13,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resizing Datagrid Columns nightmare

Hey,

I have been working on this for a while now and I keep getting the same
error.

here is my code:

------- start code ---------
Dim strSQL = "Select tagid,itemid,description,status, transtype, (select
max(datetime) from transactions where tagid = inventory.tagid) as statusdate
from inventory"

Dim connect as new SqlConnection([Sql Connection Stringgoes here])
connect.open()

Dim ds as New DataSet
Dim da as New DataAdapter(strSQL, connect)
da.Fill(ds, "Inventory")
da.FillSchema(ds.Tables("Inventory"), SchemaType.Source)

DataGrid1.DataSource = ds.Tables("Inventory")

DataGrid1.TableStyles.Clear()
Dim objTblStyle as DataGridTableStyles = new DataGridTableStyles()
objTblStyle.MappingName = "Inventory"

Dim objGridColStyles as GridColumnStylesCollection
objGridColStyles = objTblStyle.GridColumnStyles

DataGrid1.TableStyles.Add(objTblStyle)

DataGrid1.TableStyles("Inventory").AlternatingBack Color = Color.LightGray

DataGrid1.TableStyles("Inventory").GridColumnStyle s(0).Width = 150

------- end code --------

If I comment the last line of the code the code executes and the alternating
backcolors work.

with the last line uncommented, i get an Index Out of Range Error

and if i replace the (0) with ("tagid") or the name of another column I get
an Item not set to an instance of object error.

any help would be greatly appreciated.

Thanks,

Jim
Nov 20 '05 #1
0 776

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

Similar topics

1
10934
by: Gord | last post by:
Hello, Anybody know how to detect when a user drags between columns in a MSHFlexGrid when resizing column width? (Short of setting up a timer event that continuously monitors column width.)...
0
1104
by: kvinsi | last post by:
I would like grid stops with "right" resizing when mouse (spliter) come very close to the next column (sa same as it happens when you size "on the left"
3
5361
by: bismarkjoe | last post by:
Hello, I am trying to set the widths on the columns of a DataGrid component, and I'm not sure if I'm doing it correctly. My code is below: //load some inital data table = db.GetDataTable(...
4
3036
by: Dave | last post by:
Hello All, I am having a nightmare trying to add a new row to my Datagrid. When I use the code below I get the error: 'Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. Can...
1
1541
by: John Paul. A (MCP ID# 3015176) | last post by:
Hi, In a ASP.NET page I have a DataGrid Control populated with some data. I want to resize the DataGrid columns using mouse. That is, when I move the cursor to the edge of a column, the cursor...
0
1196
by: Paul | last post by:
Hi I have a datagrid with two different hyperlink columns. The columns open up a new window as the target is set to _blank for both. The windows are different sizes (one large, one small) and I...
6
1342
by: Jim Mirra | last post by:
Hey, I have been working on this for a while now and I keep getting the same error. here is my code: ------- start code --------- Dim strSQL = "Select tagid,itemid,description,status,...
4
2707
by: skOOb33 | last post by:
I successfully autosized the columns and rows on my Datagrid, and am now facing another issue. Having the sorting ability by clicking the column headers is key, but when I do that, it resizes all...
2
1756
by: Nina | last post by:
Hi there, I've tried everything that I know to prevent usre resizing datagrid columns, but nothing works. Following are the code that I used. Please tell me what's wrong with them. Thank you....
2
11469
by: lord.zoltar | last post by:
I have a DataGridView that has potentially several hundred rows (possibly a thousand or two). I'd like for each row to have the proper height to accomadate the text in the row. I tried setting the...
0
7251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
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...
0
7517
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...
0
5673
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,...
1
5072
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...
0
3230
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...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
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 ...

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.