TableStyles without GridColumnStyles ??

D

DraguVaso

Hi,

I'm having an error that I didn't really expected:
I have a DataGrid, to which I added a (empty) TableStyle like this:
dbgMulti.TableStyles.Clear()

Dim tbsTableStyle As New DataGridTableStyle

dbgMulti.TableStyles.Add(tbsTableStyle)


When I Want to use afterwuths the GridColumnStyles it doesn't work:
I got this:

?dbgmulti.TableStyles(0).GridColumnStyles.Item(0).HeaderText

Run-time exception thrown : System.ArgumentOutOfRangeException - Index was
out of range. Must be non-negative and less than the size of the collection.

Parameter name: index

Although, when I use something liek this: ?me.TableStyles(0).BackColor this
doesn't throw an exception. When I look to my DataSource on that moment I
see that it does have columns.

I just can't find out why I do have TableStyle, but no GridColumnStyles
although there are Columns in the DataGrid.

Does anybody knwo the reason for this problem and a solution?

Thanks in advance,

Pieter
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

Unfortunately, you cannot access grid column styles created automatically by
the grid. You should populate the ColumnStyles collection manually to have
control over the grid column styles.
 
D

DraguVaso

I'm affraid I don't really understand what you are saying.

I'm using some piece of code of this application:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q877q (How can I
autosize a column in my datagrid?)

In this application they do use GridColumnStyles but they didn't populate
any ColumnStyles colelction manually?

So I guess that's not the reason of my problem?


Dmitriy Lapshin said:
Hi,

Unfortunately, you cannot access grid column styles created automatically by
the grid. You should populate the ColumnStyles collection manually to have
control over the grid column styles.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

DraguVaso said:
Hi,

I'm having an error that I didn't really expected:
I have a DataGrid, to which I added a (empty) TableStyle like this:
dbgMulti.TableStyles.Clear()

Dim tbsTableStyle As New DataGridTableStyle

dbgMulti.TableStyles.Add(tbsTableStyle)


When I Want to use afterwuths the GridColumnStyles it doesn't work:
I got this:

?dbgmulti.TableStyles(0).GridColumnStyles.Item(0).HeaderText

Run-time exception thrown : System.ArgumentOutOfRangeException - Index was
out of range. Must be non-negative and less than the size of the collection.

Parameter name: index

Although, when I use something liek this: ?me.TableStyles(0).BackColor this
doesn't throw an exception. When I look to my DataSource on that moment I
see that it does have columns.

I just can't find out why I do have TableStyle, but no GridColumnStyles
although there are Columns in the DataGrid.

Does anybody knwo the reason for this problem and a solution?

Thanks in advance,

Pieter
 
D

Dmitriy Lapshin [C# / .NET MVP]

Have you downloaded the full working sample? I think that they have just
omitted the code populating the GridColumnStyles collection for the sake of
brevity.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

DraguVaso said:
I'm affraid I don't really understand what you are saying.

I'm using some piece of code of this application:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q877q (How can I
autosize a column in my datagrid?)

In this application they do use GridColumnStyles but they didn't populate
any ColumnStyles colelction manually?

So I guess that's not the reason of my problem?


Dmitriy Lapshin said:
Hi,

Unfortunately, you cannot access grid column styles created
automatically
by
the grid. You should populate the ColumnStyles collection manually to have
control over the grid column styles.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

DraguVaso said:
Hi,

I'm having an error that I didn't really expected:
I have a DataGrid, to which I added a (empty) TableStyle like this:
dbgMulti.TableStyles.Clear()

Dim tbsTableStyle As New DataGridTableStyle

dbgMulti.TableStyles.Add(tbsTableStyle)


When I Want to use afterwuths the GridColumnStyles it doesn't work:
I got this:

?dbgmulti.TableStyles(0).GridColumnStyles.Item(0).HeaderText

Run-time exception thrown : System.ArgumentOutOfRangeException - Index was
out of range. Must be non-negative and less than the size of the collection.

Parameter name: index

Although, when I use something liek this: ?me.TableStyles(0).BackColor this
doesn't throw an exception. When I look to my DataSource on that
moment
 
D

DraguVaso

Yes I downloaded the full working sample and it works fine, but now when I
try to do the same in another application it gives me that error, hehe.

Dmitriy Lapshin said:
Have you downloaded the full working sample? I think that they have just
omitted the code populating the GridColumnStyles collection for the sake of
brevity.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

DraguVaso said:
I'm affraid I don't really understand what you are saying.

I'm using some piece of code of this application:
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q877q (How can I
autosize a column in my datagrid?)

In this application they do use GridColumnStyles but they didn't populate
any ColumnStyles colelction manually?

So I guess that's not the reason of my problem?


in message news:[email protected]...
Hi,

Unfortunately, you cannot access grid column styles created
automatically
by
the grid. You should populate the ColumnStyles collection manually to have
control over the grid column styles.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Hi,

I'm having an error that I didn't really expected:
I have a DataGrid, to which I added a (empty) TableStyle like this:
dbgMulti.TableStyles.Clear()

Dim tbsTableStyle As New DataGridTableStyle

dbgMulti.TableStyles.Add(tbsTableStyle)


When I Want to use afterwuths the GridColumnStyles it doesn't work:
I got this:

?dbgmulti.TableStyles(0).GridColumnStyles.Item(0).HeaderText

Run-time exception thrown : System.ArgumentOutOfRangeException -
Index
was
out of range. Must be non-negative and less than the size of the
collection.

Parameter name: index

Although, when I use something liek this: ?me.TableStyles(0).BackColor
this
doesn't throw an exception. When I look to my DataSource on that
moment
I
see that it does have columns.

I just can't find out why I do have TableStyle, but no GridColumnStyles
although there are Columns in the DataGrid.

Does anybody knwo the reason for this problem and a solution?

Thanks in advance,

Pieter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top