473,834 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can the WinForms DataGrid be used without ADO.Net?

I am just getting into the WinForms data grid, and just about everything I
am seeing on it seems to say that the grid must be bound to an ADO.Net
dataset. I want to use the grid as a simple unbound grid-- all I want to do
is write to the grid, read from it, and allow the user to enter text in
particular cells.

Is the WinForms datagrid a viable candidate for this sort of work? If it is,
can you recommend a resource to help me get up to speed using it as a
simple, unbound grid? If it isn't a viable candidate, can you recommend a
third party grid that would be appropriate for this use?

Thanks.

--
Dave Veeneman
da****@nospam.c om
(actual domain is my last name)
Nov 15 '05 #1
3 5310
"Dave Veeneman" <no****@nospam. com> wrote in message
<snip>
I want to use the grid as a simple unbound grid-- all I want to do
is write to the grid, read from it, and allow the user to enter text in particular cells.


AFAIK, the DataGrid has to be bound to have any functionality.
However, you can create an empty DataTable that takes only
strings and bind to that. I put some code below that sets that up.
--
Michael Mayer
mr*****@charter .net
My CSharp page: http://www.mag37.com/csharp/
DataTable NewTable (int cols, int rows)
{
DataTable dt = new DataTable();
for (int c = 0; c < cols; c++)
{
dt.Columns.Add( new DataColumn("", typeof(string)) );
}
for (int r = 0; r < rows; r++)
{
DataRow dr = dt.NewRow();
for (int c = 0; c < cols; c++)
{
dr[c] = String.Empty; // initialize with empty string.
}
dt.Rows.Add(dr) ;
}
return dt;
}

private System.Windows. Forms.DataGrid dataGrid1;
private DataTable dataTable;
/******** FORM CONSTRUCTOR **/
public Form1() {
InitializeCompo nent();
this.dataTable = NewTable(4,8);
this.dataGrid1. DataSource = this.dataTable;
// prevent adding of new rows through datagrid
CurrencyManager cm = (CurrencyManage r)
this.BindingCon text[dataGrid1.DataS ource,
this.dataGrid1. DataMember];
((DataView)cm.L ist).AllowNew = false;

// now setup some values
this.dataTable. Rows[0][0] = "Hi";
this.dataTable. Rows[1][2] = "another string";
}

Nov 15 '05 #2
Good solution-- thanks!

--
Dave Veeneman
da****@nospam.c om
(actual domain is my last name)
Nov 15 '05 #3
According to MS:
The following data sources are valid:

a.. A DataTable
b.. A DataView
c.. A DataSet
d.. A DataViewManager
e.. Any component that implements the IListSource interface
f.. Any component that implements the IList interface
http://msdn.microsoft.com/library/de...ourceTopic.asp

A good example can be found here:
http://www.csharpfriends.com/Article...x?articleID=81

I personally have bound a datagrid to an arraylist and to a collection
class.

Good luck!

"Dave Veeneman" <no****@nospam. com> wrote in message
news:Ol******** ******@TK2MSFTN GP10.phx.gbl...
I am just getting into the WinForms data grid, and just about everything I
am seeing on it seems to say that the grid must be bound to an ADO.Net
dataset. I want to use the grid as a simple unbound grid-- all I want to do is write to the grid, read from it, and allow the user to enter text in
particular cells.

Is the WinForms datagrid a viable candidate for this sort of work? If it is, can you recommend a resource to help me get up to speed using it as a
simple, unbound grid? If it isn't a viable candidate, can you recommend a
third party grid that would be appropriate for this use?

Thanks.

--
Dave Veeneman
da****@nospam.c om
(actual domain is my last name)

Nov 15 '05 #4

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

Similar topics

0
1851
by: Tom Hughes | last post by:
I want to change one field of all selected rows to a provided value. Problem 1 I am using the Binding Manager Base to bind the datagrid to the appropriate dataTable as recommended by KB817247. It works in all cases but one. If the field being changed is also one the user has selected as a sort column, then all but the first selections are missed. If I remove the sort from that column before or after
5
2275
by: John Spiegel | last post by:
Hey all, I have contusions and I think a minor concussion after trying to find information on advanced WinForms DataGrid use. Does anyone know of a site / book that gets really in-depth on the DataGrid? I've found a number of postings and help topics but would like to find something that treats the DataGrid as a topic, not just a loose collection of hundreds of articles. TIA,
0
1127
by: Lucas Tam | last post by:
Hello, Sorry for the cross posts - I'm need of help... I am trying to deploy a very simple webform with the following features: -DataGrid (not yet bound) -Textboxes -Labels -Combo Box -Tab Control
5
9182
by: BBFrost | last post by:
Win2000 ..Net 1.1 SP1 c# using Visual Studio Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1 datagrid. I've come to realize that a 'block' of rows highlighted within a datagrid do >> not << constitute a set of 'selected' records. Apparently one and only one row may be 'selected' in a datagrid. By selected row I mean the row
2
4689
by: Vinny Vinn | last post by:
Any ideas on how i can bold the text within a specific cell of a winforms datagrid?i have used DataGridColumnStyle for an entire column,however currently i need just the text of a specific cell to be bold? Thanks
4
1918
by: David Krmpotic | last post by:
Hello, Can please tell me how to do it ? This should be simple, because I'd think it's used a lot.. but in reality is not that simple and there is at least 50 topics about it in newsgroups, but the problem is that people see the question and just write about overriding OnPaint or pointing to the syncfusion site without reading the question.. it's coloring the entire row, not just one cell.. I can't believe it, but there is so many...
3
2467
by: \(\( Olivier \)\) | last post by:
Hello, I've searching for the old properties MergeCol et MergeRow from MSFlexGrid in the new WinForms DataGrid control. I would like to merge all the cells wich contains the same values. How can I do that ? Thank you
3
1819
by: Tom S. | last post by:
VS.Net 2003 V 7.1.3088 ..Net Framework V 1.1.4322 SP1 WinXP SP2 I have a WinForms project that I'm having trouble with. I have a custom user control ( all code based, no visual ) and another class that is a collection of multiple instances of the control. In ASP.NET, if I wanted to bind the data of the collection ( each control having it's own row in the grid ) it was not a problem. I was also able
1
1477
by: TonyJ | last post by:
Hello! If there is a datagrid in VS2005 for winforms what kind of datagrid is it then. 1.Is it a bound datagrid that has a direct connection to columns for tables in the database. 2. Is it an open datagrid that has no connection to the databse as the bound datagrid have. We have began to use a third party datagrid that is called flygrid but I
0
9799
marktang
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...
0
10793
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
10219
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...
1
7758
isladogs
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...
0
6954
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();...
0
5627
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
5794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3081
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.