DataGridView

T

Trecius

Hello, Newsgroupians:

I'm creating a control derived from DataGridView. I'd like the user to
click a row and have the row highlight in yellow. I'd then like the user to
click a column and have the column highlight in yellow. Where the row and
column intersect, I'd like the cell to take on a red color. It's synonymous
to a grid matrix for many maps... EXA:

How many miles from one city to another:

[Chicago] [Denver] [NYC]
[Chicago] 0 750 500
[Denver ] 750 0 1000
[NYC ] 500 1000 0

However, I'm having some problems that I was wondering if the Newsgroups
could help me alleviate. First, is it possible to assign text to a row
header? Much like the example above; is it possible to put city names as row
headers? Second, I do not like the default behavior for clicking a row
header [the entire row is highlighted in blue and the arrow is displayed].
Is it possible to override the behavior? I've tried overriding
OnRowHeaderMouseClick() and put inside the method ClearSelection(), but the
computer still "blips" the background blue for a split second before it is
cleared. Any ideas? Thank you.

Trecius
 
I

Ignacio Machin ( .NET/ C# MVP )

Hello, Newsgroupians:

I'm creating a control derived from DataGridView.  I'd like the user to
click a row and have the row highlight in yellow.  I'd then like the user to
click a column and have the column highlight in yellow.  Where the row and
column intersect, I'd like the cell to take on a red color.  It's synonymous
to a grid matrix for many maps... EXA:

You should not need a new control for that.
How many miles from one city to another:

              [Chicago]  [Denver]  [NYC]
[Chicago]      0            750       500
[Denver ]      750           0        1000
[NYC     ]      500         1000        0

However, I'm having some problems that I was wondering if the Newsgroups
could help me alleviate.  First, is it possible to assign text to a row
header?  Much like the example above; is it possible to put city names as row
headers?  

Yes of course.
Use DataGridView.Columns[X].HeaderText = ""
 
D

Dom

Hello, Newsgroupians:
I'm creating a control derived from DataGridView.  I'd like the user to
click a row and have the row highlight in yellow.  I'd then like the user to
click a column and have the column highlight in yellow.  Where the row and
column intersect, I'd like the cell to take on a red color.  It's synonymous
to a grid matrix for many maps... EXA:

You should not need a new control for that.


How many miles from one city to another:
              [Chicago]  [Denver]  [NYC]
[Chicago]      0            750       500
[Denver ]      750           0        1000
[NYC     ]      500         1000        0
However, I'm having some problems that I was wondering if the Newsgroups
could help me alleviate.  First, is it possible to assign text to a row
header?  Much like the example above; is it possible to put city names as row
headers?  

Yes of course.
Use DataGridView.Columns[X].HeaderText = ""

I think the original poster wants two things:

1. He want a row (not column) headertext
2. He wants the row to remain in yellow even after the user clicks on
a column. And for this, I believe, he does need a new control.

You don't ask for advice on the second point, so I assume you have it
figured out. Concerning the first point, you can not actually enter
text into the row header, but you can freeze the first column and use
that as a header.

DataGridView.Columns[0].Frozen = true
 
T

tadmill

First, is it possible to assign text to a row header?  

This should work for the row column text
DataGridView.Rows[0].HeaderCell.Value = "Chicago";
 

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

Top