When I create this table and add it to my DataGrid (framework v1.1),
the TableStyle works fine:
DataTable dt = new DataTable();
DataColumn dc = new DataColumn("Are aCode");
DataColumn dctwo = new DataColumn("Tes t");
dt.Columns.Add( dc);
dt.Columns.Add( dctwo);
I have the style set to only show AreaCode. However, when I use a
table from the database, every column displays. AreaCode is a column
in this table, which means I should only see AreaCode in the grid.
I've looked at the grid properties in the debugger and see the
tablestyle AreaCode column is there. I also see in the DataTable a
column named AreaCode. What else do I need to look for to figure it
out?
Thanks,
Brett 9 1448
Brett,
The problem here isn't the grid and how it is set up, but rather, the
table itself. You say when you get a database from the table, this happens.
Well, are you selecting all of the fields, or some of them? If it is all of
them, then that's what you are going to see in the grid.
You need to cut down your selection so that you only select the fields
that you want.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . When I create this table and add it to my DataGrid (framework v1.1), the TableStyle works fine:
DataTable dt = new DataTable(); DataColumn dc = new DataColumn("Are aCode"); DataColumn dctwo = new DataColumn("Tes t"); dt.Columns.Add( dc); dt.Columns.Add( dctwo);
I have the style set to only show AreaCode. However, when I use a table from the database, every column displays. AreaCode is a column in this table, which means I should only see AreaCode in the grid.
I've looked at the grid properties in the debugger and see the tablestyle AreaCode column is there. I also see in the DataTable a column named AreaCode. What else do I need to look for to figure it out?
Thanks, Brett
That's not completely correct Nick. I'm doing this with a custom
datagrid. On the regular winform datagrid, I use a tablestyle to
dispay 8 of 10 fields returned in the set from a database.
This has to be something specific to my custom grid. It's puzzling
though b/c the little two column table I created works with the custom
grid. I can display 1 of 2 columns. How is that any different than
what comes from the database and is put into a dataset, which I then
reference?
It has more column than I want displayed. However, the tablestyle
takes care of that. Just not yet because I'm missing something in my
custom grid's logic, which I'm trying to pin point.
Thanks,
Brett
Brett,
Try using MappingType.Hid den to suppress display of columns you don't want
displayed, e.g.:
ds.Tables[2].Columns["DeviceTypeMode lID"].ColumnMapping = MappingType.Hid den;
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"Brett Romero" wrote: When I create this table and add it to my DataGrid (framework v1.1), the TableStyle works fine:
DataTable dt = new DataTable(); DataColumn dc = new DataColumn("Are aCode"); DataColumn dctwo = new DataColumn("Tes t"); dt.Columns.Add( dc); dt.Columns.Add( dctwo);
I have the style set to only show AreaCode. However, when I use a table from the database, every column displays. AreaCode is a column in this table, which means I should only see AreaCode in the grid.
I've looked at the grid properties in the debugger and see the tablestyle AreaCode column is there. I also see in the DataTable a column named AreaCode. What else do I need to look for to figure it out?
Thanks, Brett
Brett,
Well, post a code sample and let's see for ourselves.
DataSets that are populated from a DataAdapter tend to be no different
than anything populated by hand. However, that doesn't mean that when you
populate something by hand, you might miss what a DataAdapter might normally
set.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. . That's not completely correct Nick. I'm doing this with a custom datagrid. On the regular winform datagrid, I use a tablestyle to dispay 8 of 10 fields returned in the set from a database.
This has to be something specific to my custom grid. It's puzzling though b/c the little two column table I created works with the custom grid. I can display 1 of 2 columns. How is that any different than what comes from the database and is put into a dataset, which I then reference?
It has more column than I want displayed. However, the tablestyle takes care of that. Just not yet because I'm missing something in my custom grid's logic, which I'm trying to pin point.
Thanks, Brett
I use the MS DataAccess block, which uses an sqlhelper. It returns a
data reader, which I loop through to create a dataset. So there isn't
a data adapter involved in the code. What else can I post?
Thanks,
Brett
Hi,
"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . When I create this table and add it to my DataGrid (framework v1.1), the TableStyle works fine:
DataTable dt = new DataTable(); DataColumn dc = new DataColumn("Are aCode"); DataColumn dctwo = new DataColumn("Tes t"); dt.Columns.Add( dc); dt.Columns.Add( dctwo);
I have the style set to only show AreaCode. However, when I use a table from the database, every column displays. AreaCode is a column in this table, which means I should only see AreaCode in the grid.
I've looked at the grid properties in the debugger and see the tablestyle AreaCode column is there. I also see in the DataTable a column named AreaCode. What else do I need to look for to figure it out?
The first thing to check when DGColumnStyle's don't seem to work is whether
you have set the correct MappingName for the DGTableStyle,
DGTableStyle.Ma ppingName must be the same as the bound DataTable.Table Name.
DataGridTableSt yle dgts = new DataGridTableSt yle();
dgts.MappingNam e = someDataTable.T ableName; // !!
.... add DataGridColumnS tyles ...
someDataGrid.Ta bleStyles.Add( dgts );
someDataGrid.Da taSource = someDataTable;
HTH,
Greetings Thanks, Brett
Well, SOME code would have been helpful, but I digress.
Why are you populating the data set yourself? You should be able to
tell the data access block to populate the data set for you, using a data
adapter.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com... I use the MS DataAccess block, which uses an sqlhelper. It returns a data reader, which I loop through to create a dataset. So there isn't a data adapter involved in the code. What else can I post?
Thanks, Brett
Bart, you absolutely got it! That was the disconnect. The table name
and tablestyle mappingname were different.
I'd like to override DataSource() in my custom grid so I can look for
the table name. This way I can be sure the mapping and table names are
always the same. However, the datasource may take a dataset, datatable
or dataview. I'd need to know how to get at the table to retreive the
table name. Do I need to setup switch statements in the DataSource()
method, look for each type and extract the table name?
Thanks,
Brett
Hi,
"Brett Romero" <ac*****@cygen. com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. . Bart, you absolutely got it! That was the disconnect. The table name and tablestyle mappingname were different.
I'd like to override DataSource() in my custom grid so I can look for the table name. This way I can be sure the mapping and table names are always the same. However, the datasource may take a dataset, datatable or dataview. I'd need to know how to get at the table to retreive the table name. Do I need to setup switch statements in the DataSource() method, look for each type and extract the table name?
A little advanced, but you could use a CurrencyManager for this.
CurrencyManager .List points to the list that is actually bound, that list
will implement ITypedList if it has a name otherwise the type-name must be
used, example:
// DataMember can be an empty string (eg. when bound to DataTable)
CurrencyManager cm = (CurrencyManage r)
BindingContext[DataSource, DataMember];
ITypedList typedList = cm.List as ITypedList;
string listName = "";
if ( typedList!=null )
listName = typedList.GetLi stName(null);
else
listName = cm.List.GetType ().Name;
That should work for almost anything (DataSet, DataTable, DataView, custom
lists, arrays ).
Offcourse you could also use a switch but then it's less generic.
HTH,
Greetings Thanks, Brett This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Floela |
last post by:
I want to set a the MappingName of a DataGridTableStyle to "ArrayList" in an
ASP.NET page, but the class is stored in the System.Windows.Forms namespace.
It won't let me import the namespace at the top of my page (The type or
namespace name 'Windows' does not exist in the class or namespace 'System').
How do I create a DataGridTableStyle in ASP.NET?
|
by: Rxd |
last post by:
I have a Datagrid that should have a couple of hidden columns. I used a
DataGridTableStyle to hide the columns and it was working fine except I needed
to prevent the DataGrid from allowing new rows to be added. I was told to use a
DataView and set AddNew to false (thanks for the info btw) but now I can't use
the DataGridTableStyle to hide the columns I don't want. Is there any way to
have both hidden columns and disable AddNew in a...
|
by: Carlos |
last post by:
Does DataGridTableStyle work in ASP.net ? any time I'm tring to define a
varibale lke
DataGridTableStyle MyStyle = new DataGridTableStyle();
it give me "The Type or name sapce 'DataGridTableStyle 'could not be found"
also I have the following at the begining of the program..
using System;
|
by: Scott |
last post by:
Hi all.
A few days ago i ask this question and got a good quick response. I tried
out what they said and it worked. However I have now come to try the same
thing in another program and it does not seem to be working.
|
by: Carlos |
last post by:
Does DataGridTableStyle work in ASP.net ? any time I'm tring to define a
varibale lke
DataGridTableStyle MyStyle = new DataGridTableStyle();
it give me "The Type or name sapce 'DataGridTableStyle 'could not be found"
also I have the following at the begining of the program..
using System;
| |
by: kerpal |
last post by:
Hi all,
1. Could anyone pls clarify the difference between setting the
AlternatingBackColor property in DataGridTableStyle and in DataGrid??
2. How come BackColor and AlternatingBackColor are both associated with the
ODD-numbered rows of the grid as stated in msdn??
Thank you and happy new year!!
|
by: Brett Romero |
last post by:
I have the following DataGridTableStyle:
DataGridTableStyle gridTableStyle = new DataGridTableStyle();
gridTableStyle.MappingName = "myStyle";
DataGridTextBoxColumn dgsc = new DataGridTextBoxColumn();
dgsc.MappingName = "FirstName";
dgsc.HeaderText = "First Name";
dgsc.Width = 30;
dgsc.TextBox.Enabled = false;
gridTableStyle.GridColumnStyles.Add(dgsc);
|
by: nita |
last post by:
I'm just starting out, and it's incredibly frustrating when I see
sample code and then try to implement it.
Case in point. I'm populating a collection then binding it to a
datagrid. That works great. The problem is the columns are in the wrong
order. OK. I'll use the datagridtablestyle. But when I add the
following statement;
Dim tableStyle As New DataGridTableStyle
I get an error when I build the project;
|
by: Mitchell S. Honnert |
last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the
DataGridView? If not, is there an easy way to duplicate the
DataGridTableStyle's functionality for the DataGridView?
Here's the background for my question...
Before I switched my application over to the Fx 2.0, I used a DataGrid to
display my data. I would store different DataGridTableStyles (each one with
a custom set of columns) in the DataGrid.TableStyles property...
|
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...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
| |
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
| |