Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > VB.Net datagrid problem
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 29th October 06:54
dennis t holm
External User
 
Posts: 1
Default VB.Net datagrid problem



HEy

Im having problems with setting the width of my columns of my datagrid.
Here's the code

resultatGrid.DataSource = getFirms(0) // gets metaData from database

Dim tableStyle As New DataGridTableStyle

tableStyle.PreferredColumnWidth = 100

tableStyle.RowHeadersVisible = False

tableStyle.MappingName = "firmaer"

resultatGrid.TableStyles.Clear()

resultatGrid.TableStyles.Add(tableStyle)

Dim colStyle As GridColumnStylesCollection =
resultatGrid.TableStyles(0).GridColumnStyles

colStyle.Item("FirmaID").Width = 0

colStyle.Item("Firma Navn").Width = 200

colStyle.Item("Adresse").Width = 100

colStyle.Item("Post nr").Width = 100

colStyle.Item("By").Width = 150

colStyle.Item("CVR nr").Width = 150

I get an exception when using the colStyle.Item() commands ... it should
work but it doesnt --

I get the following exceptoin: System.NullReferenceException

Object reference not set to an instance of an object ..


MVH

Dennis Holm
  Reply With Quote


  sponsored links


2 29th October 07:01
patrick sullivan
External User
 
Posts: 1
Default VB.Net datagrid problem



Not sure if this is it, but if your mappingnames don't match actual table
and column names, the datagrid will not use them. So the values will be
nulls. hth

--

Patrick Sullivan, AA-BA, BA-IT
  Reply With Quote
3 29th October 07:19
dennis t holm
External User
 
Posts: 1
Default VB.Net datagrid problem


You are right ... it was my mapping name ... logically it has to be the
same so now its working ...

THANKS
  Reply With Quote
4 29th October 07:35
patrick sullivan
External User
 
Posts: 1
Default VB.Net datagrid problem


You welcome. Wish I could help people half as much as I've gotten it.

--

Patrick Sullivan, AA-BA, BA-IT
  Reply With Quote
5 26th February 06:43
dennis t. holm
External User
 
Posts: 1
Default VB.NET datagrid problem


HEy

Im having problems with setting the width of my columns of my datagrid.
Here's the code

resultatGrid.DataSource = getFirms(0) // gets metaData from database

Dim tableStyle As New DataGridTableStyle

tableStyle.PreferredColumnWidth = 100

tableStyle.RowHeadersVisible = False

tableStyle.MappingName = "firmaer"

resultatGrid.TableStyles.Clear()

resultatGrid.TableStyles.Add(tableStyle)

Dim colStyle As GridColumnStylesCollection =
resultatGrid.TableStyles(0).GridColumnStyles

colStyle.Item("FirmaID").Width = 0

colStyle.Item("Firma Navn").Width = 200

colStyle.Item("Adresse").Width = 100

colStyle.Item("Post nr").Width = 100

colStyle.Item("By").Width = 150

colStyle.Item("CVR nr").Width = 150

I get an exception when using the colStyle.Item() commands ... it should
work but it doesnt --

I get the following exceptoin: System.NullReferenceException

Object reference not set to an instance of an object ..


MVH

Dennis Holm
  Reply With Quote
6 27th February 03:49
ken tucker [mvp]
External User
 
Posts: 1
Default VB.NET datagrid problem


Hi,

Are you sure you spelled all the column names right? You will
get the error if the item is not in the collection.

Ken
-----------------------


HEy

Im having problems with setting the width of my columns of my datagrid.
Here's the code

resultatGrid.DataSource = getFirms(0) // gets metaData from database

Dim tableStyle As New DataGridTableStyle

tableStyle.PreferredColumnWidth = 100

tableStyle.RowHeadersVisible = False

tableStyle.MappingName = "firmaer"

resultatGrid.TableStyles.Clear()

resultatGrid.TableStyles.Add(tableStyle)

Dim colStyle As GridColumnStylesCollection =
resultatGrid.TableStyles(0).GridColumnStyles

colStyle.Item("FirmaID").Width = 0

colStyle.Item("Firma Navn").Width = 200

colStyle.Item("Adresse").Width = 100

colStyle.Item("Post nr").Width = 100

colStyle.Item("By").Width = 150

colStyle.Item("CVR nr").Width = 150

I get an exception when using the colStyle.Item() commands ... it should
work but it doesnt --

I get the following exceptoin: System.NullReferenceException

Object reference not set to an instance of an object ..


MVH

Dennis Holm
  Reply With Quote
7 10th April 14:54
calgarianø&¥ªâjwb±Ë¬²*²hœ®‹(~×(
External User
 
Posts: 1
Default VB.NET datagrid problem


I think the culprit here is: resultatGrid.TableStyles.Clear()

Please comment this line and try again.

Let me know the results.

cheers!
  Reply With Quote
8 10th April 13:20
dennis t. holm
External User
 
Posts: 1
Default VB.NET datagrid problem


HEy

Im having problems with setting the width of my columns of my datagrid.
Here's the code

resultatGrid.DataSource = getFirms(0) // gets metaData from database

Dim tableStyle As New DataGridTableStyle

tableStyle.PreferredColumnWidth = 100

tableStyle.RowHeadersVisible = False

tableStyle.MappingName = "firmaer"

resultatGrid.TableStyles.Clear()

resultatGrid.TableStyles.Add(tableStyle)

Dim colStyle As GridColumnStylesCollection =
resultatGrid.TableStyles(0).GridColumnStyles

colStyle.Item("FirmaID").Width = 0

colStyle.Item("Firma Navn").Width = 200

colStyle.Item("Adresse").Width = 100

colStyle.Item("Post nr").Width = 100

colStyle.Item("By").Width = 150

colStyle.Item("CVR nr").Width = 150

I get an exception when using the colStyle.Item() commands ... it should
work but it doesnt --

I get the following exceptoin: System.NullReferenceException

Object reference not set to an instance of an object ..


MVH

Dennis Holm
  Reply With Quote
9 20th April 07:59
ken tucker [mvp]
External User
 
Posts: 1
Default VB.NET datagrid problem


Hi,

Are you sure you spelled all the column names right? You will
get the error if the item is not in the collection.

Ken
-----------------------


HEy

Im having problems with setting the width of my columns of my datagrid.
Here's the code

resultatGrid.DataSource = getFirms(0) // gets metaData from database

Dim tableStyle As New DataGridTableStyle

tableStyle.PreferredColumnWidth = 100

tableStyle.RowHeadersVisible = False

tableStyle.MappingName = "firmaer"

resultatGrid.TableStyles.Clear()

resultatGrid.TableStyles.Add(tableStyle)

Dim colStyle As GridColumnStylesCollection =
resultatGrid.TableStyles(0).GridColumnStyles

colStyle.Item("FirmaID").Width = 0

colStyle.Item("Firma Navn").Width = 200

colStyle.Item("Adresse").Width = 100

colStyle.Item("Post nr").Width = 100

colStyle.Item("By").Width = 150

colStyle.Item("CVR nr").Width = 150

I get an exception when using the colStyle.Item() commands ... it should
work but it doesnt --

I get the following exceptoin: System.NullReferenceException

Object reference not set to an instance of an object ..


MVH

Dennis Holm
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666