|
-
May 10th, 2007, 07:19 AM
#1
Thread Starter
Just Married
[2005] DataGridView
Hi all
how to select checked row of the DataGridView view without loop
-
May 10th, 2007, 09:36 AM
#2
Re: [2005] DataGridView
 Originally Posted by shakti5385
Hi all
how to select checked row of the DataGridView view without loop
Hi,
Here's an example how to select a row:
Code:
Datagridview1.Rows(index).Selected = True
Hope it helps,
sparrow1
-
May 11th, 2007, 03:19 AM
#3
Thread Starter
Just Married
Re: [2005] DataGridView
NO in a DataGridView there is 5 rows. and the 3 rows are checked by me ( there is checkbox column on the DataGridView )
I want to count that three row without using any loop.
Thanks
-
May 30th, 2007, 03:41 AM
#4
Thread Starter
Just Married
Re: [2005] DataGridView
Any One has Any Idea
Thanks
-
May 30th, 2007, 05:38 AM
#5
Re: [2005] DataGridView
As I have suggested to you and others many times, if you have data bound to a grid then use the data source, not the grid, to manipulate the data:
vb.net Code:
Dim trueRowCount As Integer = CInt(DataTable.Compute("COUNT(ColumnName)", "ColumnName = True"))
-
May 31st, 2007, 12:59 AM
#6
Thread Starter
Just Married
Re: [2005] DataGridView
If I am not wrong then your code on the datatable not on the DataGridView?
-
May 31st, 2007, 01:16 AM
#7
Re: [2005] DataGridView
What gave it away?
Dim trueRowCount As Integer = CInt( DataTable.Compute("COUNT(ColumnName)", "ColumnName = True"))
-
May 31st, 2007, 02:44 AM
#8
Thread Starter
Just Married
Re: [2005] DataGridView
But I am asking for the DataGridView.
-
May 31st, 2007, 02:49 AM
#9
Re: [2005] DataGridView
Where does the data in the grid come from? A bound DataTable?
-
May 31st, 2007, 03:00 AM
#10
Thread Starter
Just Married
Re: [2005] DataGridView
VB.NET Code:
myGrid.DataSource=DataTable
-
May 31st, 2007, 03:05 AM
#11
Re: [2005] DataGridView
If you DataTable is bound to your DataGridView then the data in each is the same, correct? So then the number of rows in the DataTable with a particular value in a particular column is going to be the same as the number of rows in the DataGridView with that same particular value in the corresponding column. Isn't that the point of data-binding: the data in the control and the source beahve as one?
-
May 31st, 2007, 05:14 AM
#12
Thread Starter
Just Married
Re: [2005] DataGridView
But when you click on the DataGridView cell then how we can know that the datatable column is also checked?
-
May 31st, 2007, 05:19 AM
#13
Re: [2005] DataGridView
Well, I can't see why you would want to count the number of rows in a grid containing a certain value if there was still an edit pending, and having a pending edit is the only way that the data in the grid will not be in sync with the data in the DataTable.
Anyway, your question was how to count the rows without a loop. I've shown you how to do that using the bound DataTable. If you want to do it from the grid itself then you can't do it without a loop. You'd just have to check every row and test the value in that column.
-
May 31st, 2007, 05:30 AM
#14
Thread Starter
Just Married
Re: [2005] DataGridView
Yesterday you was saying to use the Binding source Class so is it necessary to use binding source is the place of datatable?
-
May 31st, 2007, 05:36 AM
#15
Re: [2005] DataGridView
You do not use a BindingSource in place of a DataTable... anywhere. A BindingSource does not contain any data of its own. A BindingSource is merely an object through which data passes and is viewed to make data-binding easier. When you populate a DataTable you bind it to a BindingSource, then bind the BindingSource to your control(s), e.g. a DataGridView.
I have shown you how to do what you've asked for. If you were supposed to use a BindingSource then my code would have included a BindingSource. It doesn't. Use the DataTable.Compute method, exactly as I have shown.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|