473,786 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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')...wi thout have to mess
with all the other columns.
If I use DataGridTableSt yle() and DataGridTextBox Column() (see following
code)...my datagrid only displays 1 column!

Dim dvFinders As New DataView(dtFind ers)
DataGrid1.DataS ource = dvFinders
' set properties
Dim x As New DataGridTableSt yle
x.MappingName = "Finders"
Dim z As New DataGridTextBox Column
z.MappingName = "lastname"
z.Width = 150
x.GridColumnSty les.Add(z)
DataGrid1.Table Styles.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 1751
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.supe rnews.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')...wi thout have to
mess
with all the other columns.
If I use DataGridTableSt yle() and DataGridTextBox Column() (see following
code)...my datagrid only displays 1 column!

Dim dvFinders As New DataView(dtFind ers)
DataGrid1.DataS ource = dvFinders
' set properties
Dim x As New DataGridTableSt yle
x.MappingName = "Finders"
Dim z As New DataGridTextBox Column
z.MappingName = "lastname"
z.Width = 150
x.GridColumnSty les.Add(z)
DataGrid1.Table Styles.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 DataGridTableSt yle for one column, you'll need to
add one for each column you want to display. If you don't want to add a
DataGridTableSt yle 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******** ********@TK2MSF TNGP15.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.supe rnews.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')...wi thout have to
mess
with all the other columns.
If I use DataGridTableSt yle() and DataGridTextBox Column() (see following
code)...my datagrid only displays 1 column!

Dim dvFinders As New DataView(dtFind ers)
DataGrid1.DataS ource = dvFinders
' set properties
Dim x As New DataGridTableSt yle
x.MappingName = "Finders"
Dim z As New DataGridTextBox Column
z.MappingName = "lastname"
z.Width = 150
x.GridColumnSty les.Add(z)
DataGrid1.Table Styles.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 DataGridTableSt yle for each column)?

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

If you are going to use DataGridTableSt yle for one column, you'll need to
add one for each column you want to display. If you don't want to add a
DataGridTableSt yle 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.supe rnews.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 DataGridTableSt yle for each
column)?

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

If you are going to use DataGridTableSt yle for one column, you'll need
to
add one for each column you want to display. If you don't want to add a
DataGridTableSt yle 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******** ********@TK2MSF TNGP14.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
5260
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 to override this implementation so that only a few or one of the columns may be sorted? thanks, -brett
4
15470
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 form for editing. the problem is when a user clicks on a cell instead of the whole row, I get an error. My question is this, is there anyway I can setup the datagrid so when the user clicks on any cell, the whole row is selected not just that...
3
3109
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 Year to Month Year) So far i have tried to use the following code: //
3
4867
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 there any way of including column headings when copying/pasting from a running datagrid to notepad? At this stage it looks like I have to write my own code but would rather not if someone knows how to do it.
2
2068
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 want it for the row I am editing. It is fine to display the new column for every row, but not a delete button for the rows that are not being edited. System.Web.UI.WebControls.ButtonColumn dc = new ButtonColumn();
5
2986
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 document into a text document with a single row for each parent node (that has all of the values from all of the child nodes for that row) The DataView within VS 2005 IDE displays my 15 or so child tables - and knows that some parent rows...
2
1387
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 either 7 columns in my DataGrid with a shared column heading for the first two columns OR I need 6 columns with the first DataGrid column showing two small ImageButtons side-by-side. PS: I need to use the DataGrid's ItemDataBound event e.g.
1
1113
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 box...how to do it... 2. How to edit the datagrid with single edit button above the datagrid and checkboxes in all the datarows. ie, by selecting the checkbox in a particular row and clicking the edit button should make that row editable...
1
4608
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 string that maps 1-to-1 to the relevant column in the dataset. I want to map three columns from my dataset to a single column in my DataGrid - is there any easy way I can do this, or am I going to have to get complicated? *Please ignore the...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
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 we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.