Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need a jump start on a DataGrid

Posted on 2006-11-02
3
Medium Priority
?
197 Views
Last Modified: 2010-04-16
Hi,

I've used DataGrids before with a database.  But i need to format and populate this one by hand.

Can anyone show me what's needed for a simple datagrid with three columns?

Here are the column types: text, double, double
and I'd like the first column to be as wide as 50%, and each of the two equal double columns to be 25%.

I will populate the columns and update them from my own collection. Although I could certainly make a collection that's designed as the data source for this DataGrid if that's easier.

Could you comment on that?

Thanks,
Bob
0
Comment
Question by:ba272
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17858189
You could easily just make an in-memory datatable and bind a grid to that. If you think thats a feasible idea let us know and we can provide code samples.
0
 

Author Comment

by:ba272
ID: 17858217
that sounds good.  I was recalling that there's a way to bind an object to a datagrid.  Is that what you mean?

I think that will work well.
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 2000 total points
ID: 17858397
                 DataSet data = new DataSet();
                  DataTable table = new DataTable("mytablename");
                  data.Tables.Add(table);
                  table.Columns.Add(new DataColumn("ID", typeof(int)));
                  table.Columns.Add(new DataColumn("FirstName", typeof(string)));
                  table.Columns.Add(new DataColumn("LastName", typeof(string)));
                  DataRow row = table.NewRow();
                  row["ID"] = 1;
                  row["FirstName"] = "John";
                  row["LastName"] = "Smith";
                  table.Rows.Add(row);
                  
                  DataGrid grid = new DataGrid();
                  grid.DataSource = data;
                  grid.DataMember = "mytablename";
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question