M
michael sorens
I have successfully bound an XmlDocument to a DataGridView but all fields
seem to be strings. I want to retrofit appropriate datatypes on some of
the fields. Let me take this in 2 parts.
Part I:
I found the ValueType field, leading me to believe that I could say
dataGridView.Columns["mean"].ValueType = typeof(Double);
dataGridView.Columns["sum"].ValueType = typeof(Integer);
etc.
I have not tried this but I suspect it would then, for example, sort a
column numerically rather than lexically when I click on the column
heading. Is that true?
Part II:
I want to dynamically adjust the bindingSource.Filter property to display
different subsets of the data in the DataGridView. So, for example, one
could say
bindingSource.Filter = "sum > 0"
This actually works now, but I just realized that it is mere coincidence,
as they are really treated as strings.
When I tried this, however:
bindingSource.Filter = "value > 5 * mean"
I received an EvaluationException saying that "*" could not be applied to
an Integer and a String. Which is due, I assume, to the fact that I set
the ValueType on the dataGridView, rather than on the bindingSource. So
how could I get this to work? I am guessing it is not as simple as just
setting the type but I need to attach a schema for the XML in some way....?
seem to be strings. I want to retrofit appropriate datatypes on some of
the fields. Let me take this in 2 parts.
Part I:
I found the ValueType field, leading me to believe that I could say
dataGridView.Columns["mean"].ValueType = typeof(Double);
dataGridView.Columns["sum"].ValueType = typeof(Integer);
etc.
I have not tried this but I suspect it would then, for example, sort a
column numerically rather than lexically when I click on the column
heading. Is that true?
Part II:
I want to dynamically adjust the bindingSource.Filter property to display
different subsets of the data in the DataGridView. So, for example, one
could say
bindingSource.Filter = "sum > 0"
This actually works now, but I just realized that it is mere coincidence,
as they are really treated as strings.
When I tried this, however:
bindingSource.Filter = "value > 5 * mean"
I received an EvaluationException saying that "*" could not be applied to
an Integer and a String. Which is due, I assume, to the fact that I set
the ValueType on the dataGridView, rather than on the bindingSource. So
how could I get this to work? I am guessing it is not as simple as just
setting the type but I need to attach a schema for the XML in some way....?