Datagrid - Windows Application

J

Jean Carlo

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
 
N

Nicholas Paldino [.NET/C# MVP]

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]
- (e-mail address removed)

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
 
J

Jean Carlo

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
 
N

Nicholas Paldino [.NET/C# MVP]

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]
- (e-mail address removed)

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
 
J

Jean Carlo

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. 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]
- (e-mail address removed)

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]
- (e-mail address removed)

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


.


.
 
D

Dmitriy Lapshin [C# / .NET MVP]

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, checkBoxColumnIndex];

--
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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top