PDA

Click to See Complete Forum and Search --> : datagridview (again)


basti42
Jul 20th, 2007, 10:01 PM
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?

jmcilhinney
Jul 20th, 2007, 10:34 PM
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: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.

basti42
Jul 20th, 2007, 10:46 PM
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!

jmcilhinney
Jul 20th, 2007, 11:59 PM
Given that the grid has column headers it is consistent to use the term "row headers" too.