PC Review


Reply
Thread Tools Rate Thread

how do highlight a specific cell in a winforms .net datagrid?

 
 
Gerg
Guest
Posts: n/a
 
      24th Jul 2003
The datagrid has a tablestyle applied to it, and there
are DataGridTextBoxColumn and each DataGridTextBoxColumn
has an array of DataGridTextBox objects.

Private Sub highlight(ByVal str As String)
Dim myTextBoxcolumn As DataGridTextBoxColumn
Dim myTextBox As DataGridTextBox

'loop through the cells of the datagrid, searching
for the string

For c As Integer = 0 To
DataGrid1.VisibleColumnCount - 1
For r As Integer = 0 To
DataGrid1.VisibleRowCount - 1

'if the content of the sell matches the
str, we want to highlight it.
If CType(DataGrid1.Item(r, c), String) =
str Then

myTextBoxcolumn = _
CType(DataGrid1.TableStyles
(0).GridColumnStyles(c), DataGridTextBoxColumn)

myTextBox = CType
(myTextBoxcolumn.TextBox, DataGridTextBox)
myTextBox.BackColor = Color.Red
myTextBox.ForeColor = Color.Blue
End If
Next
Next
End Sub

This routine highlights the entire column, not just a
single cell, moreover, you can only see the highlighting
when the cell is selected (has the focus). Is there
anyway to have the cell highlighted, even when it is not
selected? It seems that the datagrid should be capable of
this, but I cannot find any objects which expose the
necessary properties...

I can highlight an entire row, or a column, but setting
the background color on a single cell, or multiple cells
on different rows and different columns still eludes me.

If any gurus would help, I would be very appreciative.

Kind Regards,
Greg
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I focus on this cell in a winforms Datagrid control????? rhaazy Microsoft Dot NET Framework Forms 1 28th Jul 2006 08:06 PM
i would like to write my event that will react on specific keys in my custom DataGrid (WinForms)... Serdge Kooleman Microsoft C# .NET 1 20th Oct 2005 10:02 AM
Highlight a row if a specific cell is specific numbers/words =?Utf-8?B?c2VhMDIyMQ==?= Microsoft Excel Worksheet Functions 2 9th Mar 2005 12:06 AM
Winforms Datagrid Cell Text =?Utf-8?B?VmlubnkgVmlubg==?= Microsoft C# .NET 2 22nd Feb 2005 08:05 PM
Re: how do highlight a specific cell in a winforms .net datagrid? Greg Chen Microsoft Dot NET 0 25th Jul 2003 12:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.