473,761 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

bob
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.Sour ce =
myDataTable. I'm missing something fundemental here cos I get big black
nothing.

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(obje ct sender, EventArgs e)
{// create an in memory database
myDataTable2 = new DataTable("Mach ine_Events2");
myColumn2 = new DataColumn("ID" , System.Type.Get Type("System.In t32"));
myDataTable2.Co lumns.Add( myColumn2 );
myColumn2 = new DataColumn("the Time", System.Type.Get Type("System.St ring"));
myDataTable2.Co lumns.Add( myColumn2 );
myColumn2 = new DataColumn("mac hine_state",
System.Type.Get Type("System.St ring"));
myDataTable2.Co lumns.Add( myColumn2 );

myRowItem2 = myDataTable2.Ne wRow();
myRowItem2["ID"] = 1;
myRowItem2["theTime"] = "Some time";
myRowItem2["machine_st ate"] = "Some_State ";
myDataTable2.Ro ws.Add(myRowIte m2);

myRowItem2 = myDataTable2.Ne wRow();
myRowItem2["ID"] = 2;
myRowItem2["theTime"] = "more time";
myRowItem2["machine_st ate"] = "Another_State" ;
myDataTable2.Ro ws.Add(myRowIte m2);

myRowItem2 = myDataTable2.Ne wRow();
myRowItem2["ID"] = 3;
myRowItem2["theTime"] = "yet_more time";
myRowItem2["machine_st ate"] = "yet_Another_St ate";
myDataTable2.Ro ws.Add(myRowIte m2);

dataGrid1 = new DataGrid();
dataGrid1.DataS ource = 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
populated.

regards and tnx for any guidance Bob.
Feb 14 '06 #1
1 1188
bob
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

2
4333
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 how to use this code? please help! http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20862953.html
8
1957
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 button that inserts a new row in the SQL table and then refresh the datagrid.
1
3434
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 datagrid to the dataset (stored in a session variable) on the PageLoad function which works fine. But my datagrid has a button-column called EDIT which is supposed to execute some code. But during the postback,
1
4338
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 (watch the layout, some have child controls):
2
2032
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 level. Is this expected? Shouldn't anything on the properties window render accordingly? Thanks
0
1333
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 able to do it in two dataGrid. ( one datagrid containing a datagrid in each row ) But I was not able to do it in three dataGrid.
1
1638
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 DataGrid's ItemCreated event and which need to be remembered after a postback. I bind to the DataGrid in the Page_Load event when PostBack is false. The DataGrid displays the data horizontally so I set the RepeatColumns
5
2743
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 found that it comes down to whether there is a "rules=all" attribute (which gives me just a thin black line). If that attribute is not there, you get a 3D effect. I haven't yet been able to figure out what causes it. Here is the table def that...
0
1306
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 work. Explain what I have to do to make that work. Fia Imports System Imports System.Windows.Forms
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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...
0
9989
jinu1996
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...
1
9925
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,...
0
9811
tracyyun
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...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
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
3
2788
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.