Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2004

Tip: Looking for answers? Try searching our database.

Datagrid object binding + GridTableStyles

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adam - 10 Oct 2004 14:09 GMT
I am binding an arraylist of objects (class Invoice) This works fine and
binds all the public properties to the datagrid.

However, I only want to show *some* properties e.g. No, Detail and
TotalValue -- not all the public props.

After I call my gridSummary.DataSource = invoiceList;

then I create a new GridTableStyle and add some mappings, clear the existing
TableStyles then Add my new table style

*Nothing happens*... any ideas ?

Sample code:

DataGridTableStyle ts = new DataGridTableStyle();

ts.MappingName = "InvoiceList";

DataGridTextBoxColumn cs = new DataGridTextBoxColumn();

cs.MappingName = "Num"; // Public property name

cs.HeaderText = "Num";

cs.Format = "f4";

cs.Width = colwidth;

ts.GridColumnStyles.Add(cs);

cs = new DataGridTextBoxColumn();

cs.MappingName = "Detail"; // Public property name

cs.HeaderText = "Detail";

cs.Width = colwidth;

ts.GridColumnStyles.Add(cs);

// Add the custom tablestyle to the DataGrid

InvoiceSummary.TableStyles.Clear();

InvoiceSummary.TableStyles.Add(ts);
Adam - 10 Oct 2004 15:14 GMT
Sorted it.

Invoices collection was returning an Invoice[] which is an Array type

Changed to return an ArrayList which is a collection and appears to work

> I am binding an arraylist of objects (class Invoice) This works fine and
> binds all the public properties to the datagrid.
[quoted text clipped - 42 lines]
>
> InvoiceSummary.TableStyles.Add(ts);

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.