How to highlight a specific row in a datagridview
I am building a form with a datagridview and a button to add items to the datagrid view. I would like to highlight (and optionally center and not select) the row of the just added item to verify for the user what has changed. I can't seem to
get it working:
$dataGridView1.datasource = [System.Collections.ArrayList]@($list)
foreach ($Row in $dataGridView1.Rows) {
if ($Row.Name -eq $newitem.name) {
dataGridView1.Rows[$Row.Index].DefaultCellStyle.BackColor = Yellow
} else {
dataGridView1.Rows[$Row.Index].DefaultCellStyle.BackColor = white;
gives me no change. I suspect the problem is my attempt to reference properties of the Row (e.g. $Row.name), but I don't know.
I would really love a little assistance if anyone is willing.
Thanks.
Hello cascomp,
Currently, I agree with Justin. You can change the cell background color when you add a item.
I tried to accomplish your goal by myself, here is the result. I hope it can give you some ideas about your problem.
If you have any suggestions or ideas, please feel free to tell me.
Best Regards,
Greg Gu
Code:
#Generated Form Function
function GenerateForm {
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
# Generated On: 12/23/2011 9:44 AM
#region Import the Assemblies
[reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
[reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
#endregion
#region Generated Form Objects
$form1 = New-Object System.Windows.Forms.Form
$textBox1 = New-Object System.Windows.Forms.TextBox
$button1 = New-Object System.Windows.Forms.Button
$dataGridView1 = New-Object System.Windows.Forms.DataGridView
$InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
#endregion Generated Form Objects
#Generated Event Script Blocks
#Provide Custom Code for events specified in PrimalForms.
$button1_OnClick=
$newData = $textBox1.Text
$rowIndex = $dataGridView1.Rows.Add($newData)
$dataGridView1.Rows.Item($rowIndex - 1).DefaultCellStyle.BackColor = "White"
$dataGridView1.Rows.Item($rowIndex).DefaultCellStyle.BackColor = "LightGreen"
$dataGridView1.FirstDisplayedScrollingRowIndex = $rowIndex
$handler_textBox1_TextChanged=
#TODO: Place custom script here
$handler_form1_Load=
$data = "blahblahblah"
$dataGridView1.Columns.Add("ColumnA","Column A")
$dataGridView1.Columns.Add("ColumnB","Column B")
$dataGridView1.ReadOnly = $true
$dataGridView1.MultiSelect = $false
$dataGridView1.Rows.Add($data)
$dataGridView1.Rows.Item(0).Selected = $false
$OnLoadForm_StateCorrection=
{#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
#region Generated Form Code
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 262
$System_Drawing_Size.Width = 284
$form1.ClientSize = $System_Drawing_Size
$form1.DataBindings.DefaultDataSourceUpdateMode = 0
$form1.Name = "form1"
$form1.Text = "Primal Form"
$form1.add_Load($handler_form1_Load)
$textBox1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 198
$textBox1.Location = $System_Drawing_Point
$textBox1.Name = "textBox1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 20
$System_Drawing_Size.Width = 259
$textBox1.Size = $System_Drawing_Size
$textBox1.TabIndex = 2
$textBox1.add_TextChanged($handler_textBox1_TextChanged)
$form1.Controls.Add($textBox1)
$button1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 13
$System_Drawing_Point.Y = 227
$button1.Location = $System_Drawing_Point
$button1.Name = "button1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 23
$System_Drawing_Size.Width = 259
$button1.Size = $System_Drawing_Size
$button1.TabIndex = 1
$button1.Text = "Add"
$button1.UseVisualStyleBackColor = $True
$button1.add_Click($button1_OnClick)
$form1.Controls.Add($button1)
$dataGridView1.DataBindings.DefaultDataSourceUpdateMode = 0
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 12
$dataGridView1.Location = $System_Drawing_Point
$dataGridView1.Name = "dataGridView1"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 170
$System_Drawing_Size.Width = 260
$dataGridView1.Size = $System_Drawing_Size
$dataGridView1.TabIndex = 0
$form1.Controls.Add($dataGridView1)
#endregion Generated Form Code
#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($OnLoadForm_StateCorrection)
#Show the Form
$form1.ShowDialog()| Out-Null
} #End Function
#Call the Function
GenerateForm
Test result:
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Similar Messages
-
Please give me idea how I highlight the gird row which have
Sir
I have gird with 5 column
Vno
Code
Dept
Date
Amount
Sir my need is which record have above 5000 amount that color read and other color blue
It means above 5000 highlight in grid
Please give me idea how I highlight the gird row which have above 5000 maount
Thank
aamirPROCEDURE pr_Set_VA (p_VA IN VARCHAR2) IS
v_Feld VARCHAR2 (30);
v_Item VARCHAR2 (61);
v_Block VARCHAR2 (30);
BEGIN
v_Block := :SYSTEM.CURSOR_BLOCK;
v_Feld := Get_Block_Property (v_Block, FIRST_ITEM);
WHILE (v_Feld IS NOT NULL) LOOP
v_Item := v_Block || '.' || v_Feld;
Set_Item_Instance_Property (v_Item, CURRENT_RECORD, VISUAL_ATTRIBUTE, p_VA);
v_Feld := Get_Item_Property (v_Item, NEXTITEM);
END LOOP;
END; -
How to highlight the whole row of a particular line item of sale
How to highlight the whole row of a particular line item of sales order depending on condition?
Please help its urgent..
Looking forward your reply.
Moderator message: please do more research before asking, show what you have done yourself when asking, do not flag posts as "urgent".
[Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
[Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
Edited by: Thomas Zloch on Aug 9, 2011 9:30 AMAny ideas on what would cause this NOT to work? I added this row right after the table is created and populated and it is still not highlighted when I enter the form. The snippet of code that does this is:
MyTableModel modelS = (MyTableModel)dataModel.get("S");
jTable1 = new JTable(modelS);
jTable1.setRowSelectionInterval(0,0);MyTableModel is this:
class MyTableModel extends DefaultTableModel {
public MyTableModel(Object[] columnNames, int numRows) {
super(columnNames, numRows);
public boolean isCellEditable(int row, int column) {
if (TableKey == 'S') {
if (column == 6) {
return false;
if (TableKey == 'O') {
if (column == 0 || column == 4 || column == 5) {
return false;
if (TableKey == 'P') {
return false;
return true;
}Can anyone help? Thanks.
Allyson -
How to highlight a perticular row of a tabular form
Hi everybuddy,
I want to ask you 2 question.
1> How can i highlight a perticular row of a form.The requirement is that when you click any row of a form it will be highlighted by yellow color or the background color will be green.
2> I have a tabular form with five rows but when ever i want to add one button
five consiqutive buttons are add automatically.They are in a stack manner.
Can any body will please tell me how can i resolve two issues.don't duplicate:
how to highlight a perticular row of a tabular form -
Does anyone knows how to highlight every other row in numbers mac
Does anyone knows how to highlight every other row in numbers and are there any good tutorials out there???
Hi Lee,
Select a non-header cell in the table.
Open the Inspector and choose the Table Inspector.
Click to check the 'Alternating Row Color' box in the Cell Background section.
Click the Color well beside the check box to open the Color pane.
Choose a colour.
The alternating colours are applied only to the non-header rows and non-header columns in your table.
Regards,
Barry -
How to identify one specific row in the table STPO?
Hi!
How can I identify one specific row in the table STOP? As an input for my ABAP function I have MatNr, Plant, Alternative, BomUsage and Bom Position (0010, 0020...). With these values I can ask the table MAST to get the STLNR. But how can I get all needed values to specify an entry in the table STPO then?
Thanks,
KonradHere is a actual working code that we used here.
*-- get the bom details
li_mast-mandt = sy-mandt.
li_mast-matnr = material.
li_mast-werks = '6000'.
li_mast-stlan = '1'.
call function 'GET_MAST'
exporting
all = 'X'
no_buffer = 'X'
set = 'X'
tables
wa = li_mast
exceptions
call_invalid = 1
end_of_table = 2
get_without_set = 3
key_incomplete = 4
key_invalid = 5
no_record_found = 6
others = 7.
if sy-subrc <> 0.
clear: kdf_material,
kdf_material_desc.
exit.
endif.
loop at li_mast.
*-- get the valid headers
move-corresponding li_mast to li_stko.
li_stko-stlty = 'M'.
call function 'GET_STKO'
exporting
all = 'X'
datub = l_valid_date
datuv = l_valid_date
del = ' '
no_buffer = 'X'
set = 'X'
valid = 'X'
tables
wa = li_stko
exceptions
call_invalid = 1
end_of_table = 2
get_without_set = 3
key_incomplete = 4
key_invalid = 5
no_record_found = 6
others = 7.
if sy-subrc <> 0.
continue.
endif.
loop at li_stko.
move-corresponding li_stko to li_stpo.
call function 'GET_STPO'
exporting
all = 'X'
alter = li_stko-stlal
datub = l_valid_date
datuv = l_valid_date
no_buffer = 'X'
set = 'X'
valid = 'X'
* VIEWNAME =
tables
add_wa = li_cszalt
wa = li_stpo
exceptions
call_invalid = 1
end_of_table = 2
get_without_set = 3
key_incomplete = 4
key_invalid = 5
no_record_found = 6
viewname_invalid = 7
others = 8.
if sy-subrc <> 0.
continue.
else.
exit.
endif.
endloop.
if not li_stpo[] is initial.
exit.
endif.
endloop. -
How to highlight a single row in the Table components
Hi,
I am trying to do the following :
1) Select a staff member's name from a dropdown list
2) click on dropdown.name and show all the projects the member is working in a Table1
3) when clicked on the project in Table1, show all team members of selected project in Table2.
I would like to highlight the original staff member's name in Table2. Any ideas how I should go about doing it ? I tried the setSelected() method, but this selects all rows.
TIAWinston has a blog on that topic:
http://blogs.sun.com/roller/page/winston?entry=setting_table_column_style
Lark -
How to highlight the first row of a table
When entering the form, how do I get the first row of the table to be highlighted when it has not been selected yet? There is already data in the table. Thanks.
AllysonAny ideas on what would cause this NOT to work? I added this row right after the table is created and populated and it is still not highlighted when I enter the form. The snippet of code that does this is:
MyTableModel modelS = (MyTableModel)dataModel.get("S");
jTable1 = new JTable(modelS);
jTable1.setRowSelectionInterval(0,0);MyTableModel is this:
class MyTableModel extends DefaultTableModel {
public MyTableModel(Object[] columnNames, int numRows) {
super(columnNames, numRows);
public boolean isCellEditable(int row, int column) {
if (TableKey == 'S') {
if (column == 6) {
return false;
if (TableKey == 'O') {
if (column == 0 || column == 4 || column == 5) {
return false;
if (TableKey == 'P') {
return false;
return true;
}Can anyone help? Thanks.
Allyson -
How to highlight recently updated rows in gridview.?
Hi, i am using check box in my gridview control for multiple edit. I can edit my gridview rows which are selected. I would like to highlight rows after done editing. Is it possible.? If it is possible means how.?
Hi Sesuraj,
Per my understanding, you want to change the background of the table within the gridview. You can use javascript to achieve this goal. See how to do it in the following link.
http://stackoverflow.com/questions/4283141/jquery-change-background-color.
By the way, this thread is related to ASP.NET. I recommend you post thread on that forum for effective response. Please refer to the below page.
http://forums.asp.net/.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to get a specific Row based on filter on a specific column value
Friends,
I have a requirement to fetch a row, maximum salary of an employee row from employee table using ADF View object, I have a view object with result set based on some critieria, now I have to get a row out of result set which is having maximum employee salary.
Please put your thoughts or experiences!!
ThanksYou should be able to add a transient attribute called maxSalary and use groovy functions to find vo.max(Salary) like -
https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in
How to calculate ADF table column [check Laura Akel's post]Then you can create a view criteria which equates the salaryfield to maxSalary and returns just one row. -
How to highlight a specific element of an array
I'm having some trouble selecting which element in an array has key focus. I want to be able to selectively highlight individual elements in an array of strings and set the key focus so that the user can immediately enter the text into that specific element.
I have been able to get "selection.start" and "selection.end" to work, but when I get a reference to "array element" it always returns a reference to the last element manually clicked. This way, I can only programatically highlight different elements by manually clicking on them, which somewhat defeats the purpose.
Does anyone know if this is possible, or if I need to move to tables or something else in order to give me this functionality?
I'm using LV 6.1
on W2k.
Thanks
Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)I had the problem that I would like to highlight more than one cell in a 2d array.
multicolumn listbox is very slow working with large data volumes so I had to use a 2d array instead, but then I lose the possibility to highlight.
The solution I used was to bundle a LAD and control an put this in the array, takes a bit more coding but works fine.
Attachments:
2d array with marker.vi 23 KB -
How to Highlight the selected row of table
Hi All,
I have a result table. I want the selected row to be highlighted in orange color.
The properties of the table are as follows :
rowSelectable : true
selectionChangeBehaviour : auto
selectionMode : auto
Please let me know what am I missing.
NikhilHi Nikhil,
We too encountered this problem in EP 6.0. The code is correct. Actually
int index=wdContext.nodeSales_Orders1().getLeadSelection();
is enough.
But this is not the problem. It is the problem with either browser or Portal Runtime.
Is your version EP 6.0? Is this a problem for all tables or only this table? Check with other browsers like Mozilla..(or different IE versions).
regards,
Siva -
How to highlight a modified row in module pool
hi frnds,
Is it possible to highlight a row that is modified in a ztable using module pool...I have created a ztable-'zpk_table' from which i take the values n pass it to an internal table-'itab'...
i modify these values using a modify screen created in module pool..
after modifying i want the modified row to be highlighted in the next table control screen... -
Highlight specific rows in tableview
I realize that my use of the word highlight is somewhat ambiguous, in the docs its seems to be synonymous with selected. My question is: can you choose to set a background color, or somehow otherwise mimic highlighting for specific rows in a TableView? My example would be file and folder Labels in the finder. They allow a color to be displayed behind a row in the table.
You can consider 2 options. You can change your node selection property to 0..n , and loop through the node and set the selected property to true based on your logic.
You can also bind cell editor design property to context attribute and bind this attribute to columns cell editor design. You can find wiki about coloring table column. -
How to highlight/indicate particular tree Node in Tree UI element
Hi All
Can anybody let us know how to highlight/indicate specific node in a tree struture.
currently i am able to display the tree struture with all the nodes & elements but it is always tasking firstnode as highlighted one or indicated one.
if i want to highlight specific node in a tree struture...what was the procedure or any sample code then it would be great help to us.
Thanks
Trisha raniHi Krishna
Thanks for your reply
I displayed the tree structure and i want to highlight specific parent node/child element , what was the sample code??
for example my tree was displayed in the below struture and at the runtime specific child node i wanted to be highlighted i want to make selectable particular nodeType......
Can you pls send sample codee code??
my requirement
A
A1
A2
A3
B
B1
B2
B3
B4
B5
now i want to make selectable or highlighted B4,B5 etc or A2,A3 at runtime.
The other guy who replied for this thread it is working for Parent nodes to make highlighted like it is working for parent nodes which is have child nodes. i am able to hightlight at runtime for Nodes A,B etc .
Now i want to highlight or make selected one for B4,A3 etc, pls provide sample code??
it would be great help to us
Thanks
Trisha Rani
Maybe you are looking for
-
Migrated using PST, problem with replying to old mails now
Hi, we have migrated from Exchange 2007 to Exchange 2013. We built a new Exchange 2013 organization with new Active Directory... All new :) After exporting all mailboxes to PST's, we imported them using new-mailboximportrequest... Everything works fi
-
Vendor evaluation while doing SES
Hi all, is there any way i can update vendor evaluation subcriteria while doing service entry sheet. is there any field which i can update for vendor evaluation for services Po. Regards, qsm sap
-
Webi - Result from subquery / add subquery not highlighted
Hi, we have just now bought BO XI 3.1 SP3 and installed on SAP BW. .Due to the initial phase, we are currently using temporary 1 month license key from SAP until installation is done in Prod. When we build WebI query, In filter pane of webi query, wh
-
Opening an Acrobat Reader document terminates my Internet Explorer session
I'm using IE9 and recently every time I try to open an Acrobat PDF document it terminates my IE session.
-
Developping multiple level SOA approval in OIM11g
Hi Team, How to achive the below functionality in SOA work flow: 1. Once Request raised , it will to 2 managers & 1 Super Manager(approvers) queue. for Ex : M1,M2,SuperManager. ----------> 2 hours,2hours,5Hours 2. A task should be created and ,It wil