473,657 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid - Windows Application

Hello guys

I`m developing a windows form that contain one Datagrid.
In this datagrid I insert a checkBox Column. I need to get
all rows where checkbox is checked by user.
How do I get this rows ?
I canīt use the DataSource of Datagrid because I donīt
have a Column source for checkBox in my DataSource.
Is there any method in datagrid to loop in datagrid rows ?

Tks a lot.

Jean Carlo Mendes
Nov 15 '05 #1
5 2631
Jean,

How do you have a column binding without a datasource? I would think
that you have to have an underlying column to bind to.

Regardless, what you could do is get the value using the Item property
(the indexer) of the data grid. This will give you the value at a
particular row and column.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jean Carlo" <an*******@disc ussions.microso ft.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
Hello guys

I`m developing a windows form that contain one Datagrid.
In this datagrid I insert a checkBox Column. I need to get
all rows where checkbox is checked by user.
How do I get this rows ?
I canīt use the DataSource of Datagrid because I donīt
have a Column source for checkBox in my DataSource.
Is there any method in datagrid to loop in datagrid rows ?

Tks a lot.

Jean Carlo Mendes
Nov 15 '05 #2
Hi Nicholas
I have a column in my dataSource but I need to get only
rows checked by user in interface.
We donīt have an "Item" property in DataGrid... itīs my
problem...
What means "the indexer" of DataGrid ... I canīt see this
property.

Tks for your reply

[]s

Jean
-----Original Message-----
Jean,

How do you have a column binding without a datasource? I would thinkthat you have to have an underlying column to bind to.

Regardless, what you could do is get the value using the Item property(the indexer) of the data grid. This will give you the value at aparticular row and column.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jean Carlo" <an*******@disc ussions.microso ft.com> wrote in messagenews:03******* *************** ******@phx.gbl. ..
Hello guys

I`m developing a windows form that contain one Datagrid.
In this datagrid I insert a checkBox Column. I need to get
all rows where checkbox is checked by user.
How do I get this rows ?
I canīt use the DataSource of Datagrid because I donīt
have a Column source for checkBox in my DataSource.
Is there any method in datagrid to loop in datagrid rows ?

Tks a lot.

Jean Carlo Mendes
.

Nov 15 '05 #3
Jean,

If you have a column in the datasource then you should check that. The
grid is going to be bound to the datasource and when you check the grid, the
data source will be updated.

The indexer can be accessed like this:

// Get the value of first column in the first row. The data grid is named
mobjGrid.
bool pblnBool = (bool) mobjGrid[0, 0];
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jean Carlo" <an*******@disc ussions.microso ft.com> wrote in message
news:02******** *************** *****@phx.gbl.. .
Hi Nicholas
I have a column in my dataSource but I need to get only
rows checked by user in interface.
We donīt have an "Item" property in DataGrid... itīs my
problem...
What means "the indexer" of DataGrid ... I canīt see this
property.

Tks for your reply

[]s

Jean
-----Original Message-----
Jean,

How do you have a column binding without a datasource? I would thinkthat you have to have an underlying column to bind to.

Regardless, what you could do is get the value using the Item property(the indexer) of the data grid. This will give you the value at aparticular row and column.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jean Carlo" <an*******@disc ussions.microso ft.com> wrote in messagenews:03******* *************** ******@phx.gbl. ..
Hello guys

I`m developing a windows form that contain one Datagrid.
In this datagrid I insert a checkBox Column. I need to get
all rows where checkbox is checked by user.
How do I get this rows ?
I canīt use the DataSource of Datagrid because I donīt
have a Column source for checkBox in my DataSource.
Is there any method in datagrid to loop in datagrid rows ?

Tks a lot.

Jean Carlo Mendes
.

Nov 15 '05 #4
Thanks Nicholas

You are right !
I can get values. I did a loop in DataSource rows and get
values.
I made a mistake... i put the source column of my checkbox
in the last position of my sqlQuery and put the checkbox
as first column of my dataGrid... when I tried to get
checkbox value I get it in first position of item
collection.... and of course I get wrong values.

Thanks a lot !

[]s

Jean Carlo Mendes

I alredy tried to do it but I canīt see the values
-----Original Message-----
Jean,

If you have a column in the datasource then you should check that. Thegrid is going to be bound to the datasource and when you check the grid, thedata source will be updated.

The indexer can be accessed like this:

// Get the value of first column in the first row. The data grid is namedmobjGrid.
bool pblnBool = (bool) mobjGrid[0, 0];
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jean Carlo" <an*******@disc ussions.microso ft.com> wrote in messagenews:02******* *************** ******@phx.gbl. ..
Hi Nicholas
I have a column in my dataSource but I need to get only
rows checked by user in interface.
We donīt have an "Item" property in DataGrid... itīs my
problem...
What means "the indexer" of DataGrid ... I canīt see this
property.

Tks for your reply

[]s

Jean
-----Original Message-----
Jean,

How do you have a column binding without a

datasource? I would think
that you have to have an underlying column to bind to.

Regardless, what you could do is get the value using

the Item property
(the indexer) of the data grid. This will give you the

value at a
particular row and column.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Jean Carlo" <an*******@disc ussions.microso ft.com> wrote

in message
news:03****** *************** *******@phx.gbl ...
Hello guys

I`m developing a windows form that contain one Datagrid.
In this datagrid I insert a checkBox Column. I need to getall rows where checkbox is checked by user.
How do I get this rows ?
I canīt use the DataSource of Datagrid because I donīt
have a Column source for checkBox in my DataSource.
Is there any method in datagrid to loop in datagrid rows ?
Tks a lot.

Jean Carlo Mendes
.

.

Nov 15 '05 #5
Hi,

I am not sure you can have an unbound column - you should probably need to
create an underlying bogus column in the data source. But, assuming unbound
columns are possible, you can access DataGrid values by using its Item
property. The trick is that this property is visible as an indexer in C#.

Therefore your code checking if a row has been ticked will look like:

bool checked = theGrid[rowIndex, checkBoxColumnI ndex];

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jean Carlo" <an*******@disc ussions.microso ft.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
Hello guys

I`m developing a windows form that contain one Datagrid.
In this datagrid I insert a checkBox Column. I need to get
all rows where checkbox is checked by user.
How do I get this rows ?
I can?t use the DataSource of Datagrid because I don?t
have a Column source for checkBox in my DataSource.
Is there any method in datagrid to loop in datagrid rows ?

Tks a lot.

Jean Carlo Mendes

Nov 15 '05 #6

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

Similar topics

9
1731
by: Lina | last post by:
Hi, Can anyone tell me if it is possible to add link buttons to a datagrid that has its source set to a datatable that i have created? i.e i want the user to be able to select a room from various comboboxes and textboxes on my form. when they are satisfied they press OK. the row is then displayed in my datagrid. I now automaticcaly want 2 link buttons to appear next to the row that allows the user to delete the row or edit it.
2
3264
by: Tamlin | last post by:
Hi all, I'm getting a bug with the datagrid object. I've created one from scratch, bound it to a dataview with 2 int32 columns and formatted the output as currency. I've found that when you use the F2 key to enter edit mode and then hit TAB or ESCAPE without actually editing the value, dotnet crashes with a null reference error.
0
3545
by: Mauro | last post by:
Hi, I need a big help to resolve this problem. I need to put a usercontrol in a datagrid: this control check if the code inserted is present in a archive and if not return a error message. (In the example I have changed this check with a easy "if string is empty" ) Everything would be easy if the datagrid had a predictable behaviour. I explain my problem.
3
1355
by: Hoodworld | last post by:
Hi All, I have a ASP.Net application written in C# with the use of Visual Studio 2003. When I develop and test the application in my company using ASP.Net Framework 1.4.33.2 in Windows XP Enterprise Standard Edition and Windows XP Professional, the datagrid control can return all records. When I deploy all the files to the client and run it, the datagrid returns the 1st row of the whole recordset. I tried different methods to solve...
2
2351
by: Raj | last post by:
Hi, When we are sorting the DataGrid Boolean column the grid is becoming redcross. I have my own PPMIPDataGridBoolColumn class inherited from System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one DataGridValueChangedEventHandler event handler. I am overriding Edit() to know the current state of the cell. I am overriding Paint() to know the if the user has been editing the cell. I am also overriding the Commit() to
3
5032
by: Ryan Liu | last post by:
Hi there, I got a NullReferenceException when delete last row in a datagrid. I had hard time to solve since it does not occur in my own code. I put a datagrid in my inherited user control, then put this control on a form. I use DataAdaptor to fill the data table and update database.
0
1061
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 with smartnavigation enabled. In this webpage I have a button that fills the datagrid with data and creates new rows in the database. In windows XP clients this webpage works fine but only in windows 2000 clients doesn't work. The updates of the database are done but the datagrid doesn't refresh
8
1943
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.
4
1824
by: Steve | last post by:
I am fairly new to VB.NET, and I am rewriting an application I wrote a while back, also in VB.NET. I aplied some new things I learned. Anyway, here is my problem....... I have a custom DataGrid with a buttonRow that does a delete function for me. Microsoft support helped me back then to get this done. Here is part of the code that creates the dataGrid: Dim ButtonColStyle As DataGridButtonColumn
6
2742
by: Agnes | last post by:
I understand it is impossible, but still curious to know "Can I freeze several column in the datagrid, the user can only scroll the first 3 columns (not verical), for the rest of the coulumn, it is freeze.
0
8411
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
8838
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...
1
8513
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
8613
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
5638
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
4173
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
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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.