Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value
Datagridview:  get cell value Datagridview:  get cell value
Datagridview:  get cell value
Go Back  Xtreme Visual Basic Talk > > > Datagridview: get cell value


Reply
 
Thread Tools Display Modes
  #1  
Old 10-03-2006, 08:47 AM
plasticman plasticman is offline
Newcomer
 
Join Date: Oct 2006
Posts: 3
Default Datagridview: get cell value


All,

Excuse my ignorance as I am new to VB programming and have a lot to learn. What I want to do is analyze all the values of a particulair column to determine if is has a yes/no value. If it does I want to change the row color to "red." Can this be done easily? I am really just curious how to do the compare (with and "If" statement) on the cell value.

Thanks in advance.

P-man.
Reply With Quote
  #2  
Old 10-03-2006, 09:08 AM
Aquila's Avatar
Aquila Aquila is offline
Contributor
 
Join Date: Oct 2002
Location: Ocala, Fl.
Posts: 597
Default

Well.. I don't know how to change the cell or row to red (wish I did) but...

Assume that I have a datagridview on a form named dgvExample, that has two columns, the first some sort of ID and the second the boolean value (or the checkbox as you see it)

Code:
dim dgvrow as DataGridViewRow For each dgvrow in dgvExample.Rows if Convert.Toboolean(dgvRow.Cells(1)) then 'Is true, do something else 'is false do something end if Next

That's all you need to do... you could even use the hane of the cell or column if you know it. Otherwise just remember that the cell collection is zero based. (first column will be zero, the second 1, etc, etc, etc,)
__________________
Plotting to take over the world since 1978
Reply With Quote
  #3  
Old 10-03-2006, 09:12 AM
plasticman plasticman is offline
Newcomer
 
Join Date: Oct 2006
Posts: 3
Default

Aquila,

Thanks. I'll give that a try!

P-man
Reply With Quote
  #4  
Old 10-03-2006, 09:17 AM
plasticman plasticman is offline
Newcomer
 
Join Date: Oct 2006
Posts: 3
Default

Okay....that works but I guess now I have the problem of turning the row "red". I tried the following within the "If" statement:

Me.DataGridView.CurrentRow.DefaultCellStyle.BackColor = Color.Red

But this only turns the first row red. Any thoughts?

P-man.
Reply With Quote
  #5  
Old 10-03-2006, 09:43 AM
Aquila's Avatar
Aquila Aquila is offline
Contributor
 
Join Date: Oct 2002
Location: Ocala, Fl.
Posts: 597
Default

This is just a guess, but I would try
Code:
Dim x As New DataGridViewCellStyle x.BackColor = Color.Red datagridview.currentrow.defaultcellstype = x
__________________
Plotting to take over the world since 1978
Reply With Quote
  #6  
Old 11-13-2006, 09:13 AM
vanderhoof vanderhoof is offline
Freshman
 
Join Date: Feb 2006
Posts: 35
Default

I just ran into the same need of a solution as Aquila, and just wanted to state that the below quote does work. Thanks for your help.
Thomas
Quote:
Originally Posted by Aquila
This is just a guess, but I would try
Code:
Dim x As New DataGridViewCellStyle x.BackColor = Color.Red datagridview.currentrow.defaultcellstype = x
__________________
Where's the "Any" key?!?!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value Datagridview:  get cell value
Datagridview:  get cell value
Datagridview:  get cell value
 
Datagridview:  get cell value
Datagridview:  get cell value
 
-->