Unable to set DataGridViewCheckboxCell to Checked in DataGridView in a TabControl

K

Karl

Hi all...

This is a good one. You'll like this...

I am working on a course management tool that allows certain Courses
to be cross referenced with Job Roles and, when they are, whether the
course is a priority course or not. Simple.

Because there is alot of data stored for each course, I am using a tab
control with several pages. The Job Role cross-referencing comes on
tab 7 of the Tab control.

I get a list of all available Job Roles and put them into the
DataGridView.

Then I get a DataTable of all existing Job Role cross references and
if their associated "Is Priority" flag (true or false).

Once I have this cross reference list, I cycle through all the rows im
my Job Role cross reference table and, for each one, I check all the
rows in my DataGridView's rows.

If the ID of the Job Role in the DataTable Row matches the Job Role ID
in the DataGridView Row, then I set the Value of the
DataGridViewCheckBoxCell to True. If it is a match, I also check if
its a priority course and set that to it's "Is Priority" flag status.

Now. Heres the good part. I was mucking about with this for hours
today because no matter what I did, I couldn't get the checkboxes to
'check' in the DataGridView. So I decided to build a test form and cut
all the code out I didn't need to see if something was interfering,
and I got it to work!
I went back to my original code and copied all the code from the test
form and tested it, and guess what... it failed?!

Hmm. As I'd cut back for testing the process, I hadn't put the
DataGridView in a Tab Control. So I thought I'd go back to my test
form and put the DataGridView there in a new Tab Control and it still
worked! Grrr

Enough is enough I thought, so I created several more tabs on my Test
Form's Tab Control, and moved the DataGridView to the 7th Tab and
BANG! It failed! I moved the DataGridView about and discovered that it
will only work on the first tab!

So my question is this...how do I get them to work on any other tabs
than the first one?

This is in VB.net 2005 by the way. Data is in SQL Server 2005 DB.

If anyone would like to have a go at this and requires a sample
solution, please let me know.
 
K

Karl

Hi all...

This is a good one. You'll like this...

I am working on a course management tool that allows certain Courses
to be cross referenced with Job Roles and, when they are, whether the
course is a priority course or not. Simple.

Because there is alot of data stored for each course, I am using a tab
control with several pages. The Job Role cross-referencing comes on
tab 7 of the Tab control.

I get a list of all available Job Roles and put them into the
DataGridView.

Then I get a DataTable of all existing Job Role cross references and
if their associated "Is Priority" flag (true or false).

Once I have this cross reference list, I cycle through all the rows im
my Job Role cross reference table and, for each one, I check all the
rows in my DataGridView's rows.

If the ID of the Job Role in the DataTable Row matches the Job Role ID
in the DataGridView Row, then I set the Value of the
DataGridViewCheckBoxCell to True. If it is a match, I also check if
its a priority course and set that to it's "Is Priority" flag status.

Now. Heres the good part. I was mucking about with this for hours
today because no matter what I did, I couldn't get the checkboxes to
'check' in the DataGridView. So I decided to build a test form and cut
all the code out I didn't need to see if something was interfering,
and I got it to work!
I went back to my original code and copied all the code from the test
form and tested it, and guess what... it failed?!

Hmm. As I'd cut back for testing the process, I hadn't put the
DataGridView in a Tab Control. So I thought I'd go back to my test
form and put the DataGridView there in a new Tab Control and it still
worked! Grrr

Enough is enough I thought, so I created several more tabs on my Test
Form's Tab Control, and moved the DataGridView to the 7th Tab and
BANG! It failed! I moved the DataGridView about and discovered that it
will only work on the first tab!

So my question is this...how do I get them to work on any other tabs
than the first one?

This is in VB.net 2005 by the way. Data is in SQL Server 2005 DB.

If anyone would like to have a go at this and requires a sample
solution, please let me know.

I still haven't worked out why this was doing what it was doing...

The only workaround that I've found that works so far is to get my
data with the linked and priority values already attached to the
original query (use two queries - one with the relevant cross
referenced data and union to one were no cross reference exists),
then, instead of using my data as a datasource for the DataGridView, I
added columns of the right type (DataGridViewTextBoxColumn and
DataGridViewCheckBoxColumn) and then looped through the DataTable
adding the rows one by one. As I dont have too many rows this is such
a problem, but I can easily imagine it becoming a performance issue if
there were alot of data to add...

If anyone can think of a better way, please let me know...
 

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