473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

DataGrid Custom Styles

I am using ArrayDataView from the following link, my question is how do I
apply column styles to this DataGrid that uses ArrayDataView instead of
DataSet

http://www.codeproject.com/cs/databa...dArrayGrid.asp
I have tried the following code, but it has no effect

Private Sub CreateColumnStyles(ByVal grd As DataGrid)
Dim tableStyle As New DataGridTableStyle
Dim tableGrid As ArrayDataView = Nothing

Try

tableGrid = CType(grd.DataSource, ArrayDataView)
'
' Clear any existing table styles.
'
grd.TableStyles.Clear()
'
' Use mapping name that is defined in the data source.
'
tableStyle.MappingName = ""
'
' Now create the column styles within the table style.
'
Dim columnStyle As DataGridTextBoxColumn
Dim currCol As Integer
Dim colNames As String() = tableGrid.ColumnNames()

For currCol = 0 To tableGrid.Data.GetUpperBound(0) - 1

columnStyle = New DataGridTexBoxColumn
With columnStyle
.HeaderText = colNames(currCol)
.MappingName = colNames(currCol)
.NullText = ""
End With
'
' Add the new column style to the table style.
'
tableStyle.AlternatingBackColor =
System.Drawing.Color.Lavender
tableStyle.GridColumnStyles.Add(columnStyle)
Next currCol
'
' Add the new table style to the data grid.
'
grd.TableStyles.Add(tableStyle)
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub

I have implemented the ITypeList in the ArrayDataView , but what do I return
forom
PropertyDescriptorCollection and GetListName
#region ITypedList Members

public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[]
listAccessors)
{
// TODO: Add ArrayDataView.GetItemProperties implementation
return null;
}

public string GetListName(PropertyDescriptor[] listAccessors)
{
// TODO: Add ArrayDataView.GetListName implementation
return null;
}

#endregion
Thank You
Peter

Mar 23 '06 #1
3 2887
Peter,

I think that you would ask that to Mihail.

The datagrid is not that control that is made to use with every collection
class. One of the advantages of the DataGridView should be that this has
more posibilities in this.

Cor

"Peter" <pc*****@nospam.nospam> schreef in bericht
news:ev**************@TK2MSFTNGP09.phx.gbl...
I am using ArrayDataView from the following link, my question is how do I
apply column styles to this DataGrid that uses ArrayDataView instead of
DataSet

http://www.codeproject.com/cs/databa...dArrayGrid.asp
I have tried the following code, but it has no effect

Private Sub CreateColumnStyles(ByVal grd As DataGrid)
Dim tableStyle As New DataGridTableStyle
Dim tableGrid As ArrayDataView = Nothing

Try

tableGrid = CType(grd.DataSource, ArrayDataView)
'
' Clear any existing table styles.
'
grd.TableStyles.Clear()
'
' Use mapping name that is defined in the data source.
'
tableStyle.MappingName = ""
'
' Now create the column styles within the table style.
'
Dim columnStyle As DataGridTextBoxColumn
Dim currCol As Integer
Dim colNames As String() = tableGrid.ColumnNames()

For currCol = 0 To tableGrid.Data.GetUpperBound(0) - 1

columnStyle = New DataGridTexBoxColumn
With columnStyle
.HeaderText = colNames(currCol)
.MappingName = colNames(currCol)
.NullText = ""
End With
'
' Add the new column style to the table style.
'
tableStyle.AlternatingBackColor =
System.Drawing.Color.Lavender
tableStyle.GridColumnStyles.Add(columnStyle)
Next currCol
'
' Add the new table style to the data grid.
'
grd.TableStyles.Add(tableStyle)
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub

I have implemented the ITypeList in the ArrayDataView , but what do I
return forom
PropertyDescriptorCollection and GetListName
#region ITypedList Members

public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[]
listAccessors)
{
// TODO: Add ArrayDataView.GetItemProperties implementation
return null;
}

public string GetListName(PropertyDescriptor[] listAccessors)
{
// TODO: Add ArrayDataView.GetListName implementation
return null;
}

#endregion
Thank You
Peter

Mar 23 '06 #2
Hi Peter,

Thanks for your post!

We can return a meaningful string for GetListName() method. Regarding
GetItemProperties() method, it requires some extra work to be done. You can
get some information regarding implementing this interface from the
articles below:
http://noiseehc.freeweb.hu/IListSource.html
http://www.freeweb.hu/noiseehc/DS.cs
"Really complex databinding: ITypedList with weakly typed collections "
http://weblogs.asp.net/fbouma/articles/115837.aspx

You may give this a try. However, I agree with "Cor Ligthert [MVP]" that
because we are not the author of the article, you'd better contact the
article author for the help regarding his article.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 23 '06 #3
Peter,

In addition to the other comments. To use a table style with a
datagrid bound to an arraylist use arraylist as the tablestyles mapping
name. For collection use collection as the mapping name. A blank mapping
name will never work. I would try ArrayDataView for the mapping name.

Ken
---------------
"Peter" <pc*****@nospam.nospam> wrote in message
news:ev**************@TK2MSFTNGP09.phx.gbl...
I am using ArrayDataView from the following link, my question is how do I
apply column styles to this DataGrid that uses ArrayDataView instead of
DataSet

http://www.codeproject.com/cs/databa...dArrayGrid.asp
I have tried the following code, but it has no effect

Private Sub CreateColumnStyles(ByVal grd As DataGrid)
Dim tableStyle As New DataGridTableStyle
Dim tableGrid As ArrayDataView = Nothing

Try

tableGrid = CType(grd.DataSource, ArrayDataView)
'
' Clear any existing table styles.
'
grd.TableStyles.Clear()
'
' Use mapping name that is defined in the data source.
'
tableStyle.MappingName = ""
'
' Now create the column styles within the table style.
'
Dim columnStyle As DataGridTextBoxColumn
Dim currCol As Integer
Dim colNames As String() = tableGrid.ColumnNames()

For currCol = 0 To tableGrid.Data.GetUpperBound(0) - 1

columnStyle = New DataGridTexBoxColumn
With columnStyle
.HeaderText = colNames(currCol)
.MappingName = colNames(currCol)
.NullText = ""
End With
'
' Add the new column style to the table style.
'
tableStyle.AlternatingBackColor =
System.Drawing.Color.Lavender
tableStyle.GridColumnStyles.Add(columnStyle)
Next currCol
'
' Add the new table style to the data grid.
'
grd.TableStyles.Add(tableStyle)
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub

I have implemented the ITypeList in the ArrayDataView , but what do I
return forom
PropertyDescriptorCollection and GetListName
#region ITypedList Members

public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[]
listAccessors)
{
// TODO: Add ArrayDataView.GetItemProperties implementation
return null;
}

public string GetListName(PropertyDescriptor[] listAccessors)
{
// TODO: Add ArrayDataView.GetListName implementation
return null;
}

#endregion
Thank You
Peter

Mar 23 '06 #4

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

Similar topics

0
by: shravan | last post by:
Hi, I have a extended Windows Forms Datagrid, I have custom column styles defined for it. The problem is when I am in the new row and pressing escape two times - First time it's cancelling cell...
0
by: RFickling | last post by:
Hi, I have a DataGrid with custom ComboBox and DataTimePicker controls in column styles. When I add a new row, typing values into all columns, then close the form, I get a...
2
by: Jim Dougherty | last post by:
I am using c#.net 2003 and have an an application with a datagrid. The binding is with an array of structs. Everything works ok except the header text is the struct element names and they override...
1
by: Vagabond Software | last post by:
I am creating a custom datagrid based, in part, from someone else's code. The author declared a derived datagrid class in a windows form, then declared a derived ColumnStyle class, in the same form,...
3
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
3
by: Richard | last post by:
Rather than all that painting, brush, etc. code to change the styles of a ..NET datagrid to start with and on the fly, I'd rather be able to set a lot of the stuff in the designer properties of the...
6
by: Bob The Builder | last post by:
I have a custom-built datagrid for windows forms. I overrode the scrollbars in it because I wanted to draw my own (basically, they're skinned). As a result, I handle all scroll events and calls. ...
4
by: Peter | last post by:
I am using ArrayDataView from the following link, my question is how do I apply column styles to this DataGrid that uses ArrayDataView instead of DataSet ...
1
by: Steve | last post by:
C# WinForms I am trying to find a good solution for changing the color of a row in a datagrid, at runtime, based on the contents of a certain cell of the row, or a related value in the database....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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
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...

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.