473,834 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating WinForms DataGrid

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
to select only the column I wanted displayed by defining
the grid. But I can't figure out how to do this in
WinForms. I am able to populate the DataGrid without a
problem ( I've set the DataSource property to the
collection ), but I can't find out how to hide columns
that I don't want displayed.
Any help would be greatly appreciated!! Thanks!!

Tom S.
Nov 21 '05 #1
3 1819
Tom S. wrote:
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
to select only the column I wanted displayed by defining
the grid. But I can't figure out how to do this in
WinForms. I am able to populate the DataGrid without a
problem ( I've set the DataSource property to the
collection ), but I can't find out how to hide columns
that I don't want displayed.
Any help would be greatly appreciated!! Thanks!!

Tom S.


You need to look at the DataGridTableSt yles class. That is how I always
limit what columns to show/hide. There may be another way....

Chris
Nov 21 '05 #2
This is also my question :
The topic of my thread is "Datagrid customization for custom objects".
Tom S. wrote:
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
to select only the column I wanted displayed by defining
the grid. But I can't figure out how to do this in
WinForms. I am able to populate the DataGrid without a
problem ( I've set the DataSource property to the
collection ), but I can't find out how to hide columns
that I don't want displayed.
Any help would be greatly appreciated!! Thanks!!

Tom S.

Nov 21 '05 #3
I've tried using the DataGridTableSt yles, but from
everything I've read, you need to have a DataMember
assinged to the grid. But since this is a custom object
and not a collection of different tables from a database,
I can't use a data adapter with it, and therefore can't
assign a DataMember.
If I am incorrect in this, please let me know ( as I have
just been playing with this for a few days ). Otherwise,
are there any other suggestions??
Thanks!
-----Original Message-----
Tom S. wrote:
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 to select only the column I wanted displayed by defining the grid. But I can't figure out how to do this in
WinForms. I am able to populate the DataGrid without a
problem ( I've set the DataSource property to the
collection ), but I can't find out how to hide columns
that I don't want displayed.
Any help would be greatly appreciated!! Thanks!!

Tom S.
You need to look at the DataGridTableSt yles class. That

is how I alwayslimit what columns to show/hide. There may be another way....
Chris
.

Nov 21 '05 #4

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

Similar topics

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,
3
5311
by: Dave Veeneman | last post by:
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...
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
10575
by: Robert | last post by:
I'm sure this is a fairly basic question, but I've been looking all over the web for days for suggestions on how to do this. I've got a datagrid that's bound to a dataset on my form. It includes several columns, the last of which (with the header Quantity) contains int16 values. When a user selects a row, I would like to have a combobox on the form display the values from 1 to the number in the Quantity column (e.g., the selected row has...
4
3932
by: Paul | last post by:
I sometimes get a timeout error when populating my datagrid, the code is WizardConnection.Open() UpdateCommand.CommandText = "EXECUTE sp_assign_user '" & PhysOffice.SelectedValue & "', '" & Context.User.Identity.Name & "'" UpdateCommand.ExecuteNonQuery()
5
2296
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a collection object -- say, a dictionary. Populating that collection object with custom objects, say, Person. What I really want to see is how to populate the properties of those Person objects from a datasource: instantiate one Person, fill...
6
1809
by: fripper | last post by:
I want to populate the cells of a DataGrid at run time. I don't want to bind a database to it I simply want to do some calculations and put results into the grid programmatically. I did this in VB 6.0 using the FlexGrid control but the I cannot figure out how to specify the row/column of the cell I want to set in the .Net DataGrid control and how to set its value. Thanks for your help.
1
1777
by: Mike P | last post by:
I am populating a drop down column in a datagrid on page load. Here is my code : <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt" Runat=server DataValueField="UserName" DataTextField="UserName" DataSource='<%# GetUserList() %>'>
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
9646
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
10795
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
10512
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
10550
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
9332
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6957
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
5796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
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

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.