473,395 Members | 2,468 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,395 software developers and data experts.

Modify a single column in a datagrid?

Is there a way to programatically set the format of just one column in a
datagrid? I have a datagrid bined to a datasource. My dataview has 6
columns. And I want to format one column ('amount')...without have to mess
with all the other columns.
If I use DataGridTableStyle() and DataGridTextBoxColumn() (see following
code)...my datagrid only displays 1 column!

Dim dvFinders As New DataView(dtFinders)
DataGrid1.DataSource = dvFinders
' set properties
Dim x As New DataGridTableStyle
x.MappingName = "Finders"
Dim z As New DataGridTextBoxColumn
z.MappingName = "lastname"
z.Width = 150
x.GridColumnStyles.Add(z)
DataGrid1.TableStyles.Add(x)

This datagrid is making my project a lot harder than it should be!

Any help is appreciated!
-bruce duncan
Nov 21 '05 #1
5 1707
If you are going to use DataTable for one column, you'll need to add one for
each column you want to display. If you don't want to add a tablestyle for
each column, then add a column to your datatable (dataview has a datatable)
and for the column directly on the datatable.

Chris
"Bruce D" <br*************@hotmail.com> wrote in message
news:11*************@corp.supernews.com...
Is there a way to programatically set the format of just one column in a
datagrid? I have a datagrid bined to a datasource. My dataview has 6
columns. And I want to format one column ('amount')...without have to
mess
with all the other columns.
If I use DataGridTableStyle() and DataGridTextBoxColumn() (see following
code)...my datagrid only displays 1 column!

Dim dvFinders As New DataView(dtFinders)
DataGrid1.DataSource = dvFinders
' set properties
Dim x As New DataGridTableStyle
x.MappingName = "Finders"
Dim z As New DataGridTextBoxColumn
z.MappingName = "lastname"
z.Width = 150
x.GridColumnStyles.Add(z)
DataGrid1.TableStyles.Add(x)

This datagrid is making my project a lot harder than it should be!

Any help is appreciated!
-bruce duncan

Nov 21 '05 #2
*Corrected wording

If you are going to use DataGridTableStyle for one column, you'll need to
add one for each column you want to display. If you don't want to add a
DataGridTableStyle for each column, then add a column to your datatable
(dataview has a datatable) and for the column directly on the datatable.

Chris

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:%2****************@TK2MSFTNGP15.phx.gbl...
If you are going to use DataTable for one column, you'll need to add one
for each column you want to display. If you don't want to add a
tablestyle for each column, then add a column to your datatable (dataview
has a datatable) and for the column directly on the datatable.

Chris
"Bruce D" <br*************@hotmail.com> wrote in message
news:11*************@corp.supernews.com...
Is there a way to programatically set the format of just one column in a
datagrid? I have a datagrid bined to a datasource. My dataview has 6
columns. And I want to format one column ('amount')...without have to
mess
with all the other columns.
If I use DataGridTableStyle() and DataGridTextBoxColumn() (see following
code)...my datagrid only displays 1 column!

Dim dvFinders As New DataView(dtFinders)
DataGrid1.DataSource = dvFinders
' set properties
Dim x As New DataGridTableStyle
x.MappingName = "Finders"
Dim z As New DataGridTextBoxColumn
z.MappingName = "lastname"
z.Width = 150
x.GridColumnStyles.Add(z)
DataGrid1.TableStyles.Add(x)

This datagrid is making my project a lot harder than it should be!

Any help is appreciated!
-bruce duncan


Nov 21 '05 #3
Thanks Chris!
How about another question? I have a DataTable that has both lastname,
firstname as seperate fields. How can I display them as one field in the
datagrid (and yes...I was forced to use DataGridTableStyle for each column)?

TIA
-bruce
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:Ox**************@TK2MSFTNGP15.phx.gbl...
*Corrected wording

If you are going to use DataGridTableStyle for one column, you'll need to
add one for each column you want to display. If you don't want to add a
DataGridTableStyle for each column, then add a column to your datatable
(dataview has a datatable) and for the column directly on the datatable.

Chris

Nov 21 '05 #4
I assume you are getting your data out of a database? In that case I would
do it in your select statement.

Select FirstName + ' ' + LastName as Name, TableName.* from TableName

There may be a nice slick way of doing it client side, but this is how I've
always done stuff like that.
Chris
"Bruce D" <br*************@hotmail.com> wrote in message
news:11*************@corp.supernews.com...
Thanks Chris!
How about another question? I have a DataTable that has both lastname,
firstname as seperate fields. How can I display them as one field in the
datagrid (and yes...I was forced to use DataGridTableStyle for each
column)?

TIA
-bruce
"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com>
wrote
in message news:Ox**************@TK2MSFTNGP15.phx.gbl...
*Corrected wording

If you are going to use DataGridTableStyle for one column, you'll need
to
add one for each column you want to display. If you don't want to add a
DataGridTableStyle for each column, then add a column to your datatable
(dataview has a datatable) and for the column directly on the datatable.

Chris


Nov 21 '05 #5
Thanks for the response, but I was looking for the client side answer.

-bruce

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:%2****************@TK2MSFTNGP14.phx.gbl...
I assume you are getting your data out of a database? In that case I would do it in your select statement.

Select FirstName + ' ' + LastName as Name, TableName.* from TableName

There may be a nice slick way of doing it client side, but this is how I've always done stuff like that.
Chris

Nov 21 '05 #6

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

Similar topics

3
by: Brett P. | last post by:
Hello, I am trying to have only one column sortable within a data grid. I know you set the allow sorting property to true on the style, but this enables sorting for all columns. Is there a way...
4
by: Terry | last post by:
Hey, Having somewhat of an issue, I have a datagrid which is giving me issues. The Datagrid is setup for the user to double click the row, the row is selected and data within that row populates a...
3
by: KevLow | last post by:
Hi, Hope some kind soul can help me out here.. I'm trying to programmatically modify the column headings of a crosstab query such that it can be dynamic based on user specified period (Month...
3
by: PeterZ | last post by:
Hi, In a running C# app with a datagrid control I select all rows in the dataGrid using CTRL-A, I then paste into some other app like notepad or Word but the column headings get left off. Is...
2
by: localhost | last post by:
When I go into Edit mode on a datagrid, I would like to add a single column to the edited row and display a hyperlink. If I use the code below, I get a delete linkbutton in every row, when I only...
5
by: BMeyer | last post by:
I have been losing my mind trying to parse an XML document (with nested child elements, not all of which appear in each parent node) into a DataGrid object. What I want to do is "flatten" the XML...
2
by: mark4asp | last post by:
This page is currently using a Repeater control to create a table with 6 columns. The first column has 2 ImageButton controls and a common header. How can I do this with a DataGrid ? I need...
1
by: miferdin | last post by:
Hi friends, 1. I have a datagrid with 5 columns, in this when i click edit in a row, all the columns changes into textbox but what i need is to make only a single column into a text...
1
by: yumbelie | last post by:
Hi, I want to set multiple datafields from a dataset to a single boundcolumn in my gridview, but I can't see any easy way to do this since the DataField property of the boundcolumn takes a single...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.