473,326 Members | 2,196 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,326 software developers and data experts.

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.com
(actual domain is my last name)
Nov 15 '05 #1
3 5257
"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() {
InitializeComponent();
this.dataTable = NewTable(4,8);
this.dataGrid1.DataSource = this.dataTable;
// prevent adding of new rows through datagrid
CurrencyManager cm = (CurrencyManager)
this.BindingContext[dataGrid1.DataSource,
this.dataGrid1.DataMember];
((DataView)cm.List).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.com
(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**************@TK2MSFTNGP10.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.com
(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
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....
5
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...
0
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...
5
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...
2
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...
4
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,...
3
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. ...
3
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...
1
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.