473,247 Members | 3,145 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,247 software developers and data experts.

Can't get a my DataGrid to work .. I'm busted or its busted

I cannot seem to display any info with my Data Grid ... the online examples
I have seen 'appear' to say the same thing.
create a DataTable then simply call something like this myDataGrid.Source =
myDataTable. I'm missing something fundemental here cos I get big black

here's some code snippets.

public class Form1 : System.Windows.Forms.Form
// declarations section

private System.Windows.Forms.DataGrid dataGrid1;
private DataTable myDataTable2;
private DataColumn myColumn2;
private DataRow myRowItem2;

private void Form1_Load(object sender, EventArgs e)
{// create an in memory database
myDataTable2 = new DataTable("Machine_Events2");
myColumn2 = new DataColumn("ID", System.Type.GetType("System.Int32"));
myDataTable2.Columns.Add( myColumn2 );
myColumn2 = new DataColumn("theTime", System.Type.GetType("System.String"));
myDataTable2.Columns.Add( myColumn2 );
myColumn2 = new DataColumn("machine_state",
myDataTable2.Columns.Add( myColumn2 );

myRowItem2 = myDataTable2.NewRow();
myRowItem2["ID"] = 1;
myRowItem2["theTime"] = "Some time";
myRowItem2["machine_state"] = "Some_State";

myRowItem2 = myDataTable2.NewRow();
myRowItem2["ID"] = 2;
myRowItem2["theTime"] = "more time";
myRowItem2["machine_state"] = "Another_State";

myRowItem2 = myDataTable2.NewRow();
myRowItem2["ID"] = 3;
myRowItem2["theTime"] = "yet_more time";
myRowItem2["machine_state"] = "yet_Another_State";

dataGrid1 = new DataGrid();
dataGrid1.DataSource = myDataTable2;

Sorry bout the poor formatting ... when I debug and scroll through the
watch window it certainly appears that myDataTable2 exists and is populated
... datagrid1 doesn't seem to believe so. I dropped the datagrid in with
using VS2003 IDE .. so all the windows form designer code is untouched ...
and it certainly displays the blank DataGrid when I execute ... just not

regards and tnx for any guidance Bob.
Feb 14 '06 #1
1 1167
OK ... so there are some trees there in that forest ... I'll take my foot
out of my mouth now.

I figured it out ... went bit mad declaring things ... redeclared the
datagrid1 control ...
Feb 14 '06 #2

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

Similar topics

by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
by: Inigo Jimenez | last post by:
I have an ASP .net web application installed in a Windows 2003 server. This web application has a webform that has a Datagrid. This Datagrid is filled with the data of a SQL table. I have a...
by: Michelle Stone | last post by:
Hi all. I have an empty datagrid on my web form. And I add BoundDataColumn(s) to it through code. But after each postback, the columns and rows disappear. As a workabout, I tried to rebind the...
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
by: Marty McDonald | last post by:
When setting certain datagrid properties with the IDE (as in the property window), they don't seem to take effect. For instance, Font Name. So I have to set these via code-behind at the cell...
by: BK Kim | last post by:
Hello. I am trying to use dataGrid in a dataGrid, meaning first DataGrid displays some information and on each row, it is going to have another datagrid to display detailed information. I was...
by: wh1974 | last post by:
I'm not sure if i'm heading in the right direction so would appreciate any comments on what I'm trying to do. Basically I have a DataGrid on a page which has columns whose width's I set in the...
by: tshad | last post by:
I have been trying to figure out what the Datagrid is doing to create its formatting. I found that some of my Datagrids have a 3D type of border and sometime it has a straight line. I finally...
by: Familjen Karlsson | last post by:
Hi I have downloaded some code and tried it and nothing happens with the datagrid. Explain what is wrong and what I have to do please. I have tried to Import the namespace Hamster and it didn't...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.