The datagrid has a tablestyle applied to it, and there
are DataGridTextBox Column and each DataGridTextBox Column
has an array of DataGridTextBox objects.
Private Sub highlight(ByVal str As String)
Dim myTextBoxcolumn As DataGridTextBox Column
Dim myTextBox As DataGridTextBox
'loop through the cells of the datagrid, searching
for the string
For c As Integer = 0 To
DataGrid1.Visib leColumnCount - 1
For r As Integer = 0 To
DataGrid1.Visib leRowCount - 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).GridColumnS tyles(c), DataGridTextBox Column)
myTextBox = CType
(myTextBoxcolum n.TextBox, DataGridTextBox )
myTextBox.BackC olor = Color.Red
myTextBox.ForeC olor = 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 1 5017
hello,
i am able to highlight the cell only but the same problem problem as yours i am also getting. i.e. when the user clicks the other cell of the datagrid, then the previously highlighted color of the cell is not preserved. i want to make highlighting that cell despite of user clciking on the other cell.
have u done anything on this. i am sending u the code that can highlight the cell only.
for (int row = 0; row < totalRows - 1; row++)
{
for (int col = 0; col < totalCols; col++)
{
string result= ,,,,,,,,// u can call the function of word searching
if (result != null)
{
int index = ((string)<datag ridname>[col, row].Value).IndexOf (result);
int length = result.Length;
dgsource[col, row].Selected = true;
dgsource[col, row].Style.Selectio nBackColor = color name;
}
}
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Graham Y |
last post by:
I have a datagrid, populated via a SQL dataset, and I want the user to select
a row by clicking on it and then using the value in the first cell as my key
for my next query. Using CurrentCellChanged works unless I want the row which
has a cell selected and I click on that cell, obvious answer click another
cell in that row, but I have to code for stupid users!
I tried the click event but that didn't work, maybe I was doing something
wrong....
|
by: Nanda |
last post by:
Hi all,
while editing a datagrid cell, if i press Enter key
focus goes to the next row, instead that i would like to
have focus on next cell, how can i obtain this.
Thanks & Regards,
Nanda
|
by: Michael Ramey |
last post by:
I'm using the following code to highlight the current row:
private void Datagrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
DataGrid1.Select(DataGrid1.CurrentRowIndex);
}
The entire row is selected, but the cell with cursor in it, shows the grid
value as selected. The looks strange. Is there a way to eliminate the cell
selection?
|
by: mike |
last post by:
I'm trying to highlight a specific row in a datagrid who's contition matches
..text = "Dawn"
i've been playing with the code below without much luck, is there a foreach
loop i could do, like
(
foreach(datarows in datagrid)
check if the first cell in the row contains Dawn
if so highlight the row.
)
|
by: Ben Bloom |
last post by:
I've got a datagrid with a column named "Type". If cells in this column
contain "Error" I would like to highlight them (say - turn the text red,
or the background red.)
How do I do this? Is there an example out there somewhere?
Thanks!
--
to reply, remove .s.p.a.m. from email
| |
by: Geraldine Hobley |
last post by:
Hello
I have a datagrid, called MyDataGrid and I wish to put the focus on a particular cell in order that the user to highlight the fact that the user needs to enter a value in this cell, e.g. I put the message up "Please enter an order number" I then wish to highlight the column MyDataGrid(0,1), but I can't find out how to do this
Many thanx in advance
Geri
|
by: Don |
last post by:
George Shepherd's great Windows Forms FAQ has this article about creating a
datagrid with no active cell:
http://www.syncfusion.com/faq/winforms/search/856.asp
Unfortunately, this only works properly for datagrids that are not ReadOnly
(i.e. a row will become unhighlighted if you click the same cell twice).
Has anyone discovered a way to have a read-only datagrid with no active
cell?
|
by: Gerg |
last post by:
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
|
by: Sharon |
last post by:
I want put into my DataGrid different control types in the same column.
For example:
Column 1, row 0 ==> TextBox
Column 1, row 2 ==> CheckBox
Column 1, row 2 ==> ComboBox
etc...
As I see, I can hold only one kind of sell type in the same column. is there
a way to do it anyway.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |