|
-
Jul 20th, 2007, 10:01 PM
#1
Thread Starter
Hyperactive Member
datagridview (again)
i still have question about datagridview
1.how can set the width dynamically of the datagrid pointer or the record selector i can't find it's properties to hide or set the width.
2. example i have these i load the data in datagridview:
column1
2
4
2
5
the sum is 15
label1.text = sum of column1
how?
*****************
VB6,PHP,VS 2005
-
Jul 20th, 2007, 10:34 PM
#2
Re: datagridview (again)
1. I assume you mean the row headers down the left-hand side of the grid. That would be the RowHeaderWidth property.
2. I'm going to assume that your data is coming from a DataTable. If that's incorrect please let me know. Firstly you should bind your DataTable to a BindingSource, then bind that to the grid. To get the sum of the values in Column1 of the DataTable you'd do this:
C# Code:
int sum = (int)myDataTable.Compute("SUM(Column1)", myBindingSource.Filter);
That will sum all the rows and only the rows that are displayed in the grid. If you have set the Filter property of the BindingSource to exclude some rows from the grid, that code will allow for that and not include those rows in the calculation.
-
Jul 20th, 2007, 10:46 PM
#3
Thread Starter
Hyperactive Member
Re: datagridview (again)
OH MY GOD!, I didn't try the "RowHeaderVisible = false" because of its name (ROWHEADER) its better to name it ROWPOINTER or SELECTOR
and i thought the Record Selector is not listed in the porperty.
yes mydata are on data table... i'll try what you suggested, i trust you...
anyways, glad to hear from you again. TNX!
*****************
VB6,PHP,VS 2005
-
Jul 20th, 2007, 11:59 PM
#4
Re: datagridview (again)
Given that the grid has column headers it is consistent to use the term "row headers" too.
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
|