Multiple row selected in a grid with colored rows

I have a grid that have different colors rows based on some criteria.
when I select multiple rows that have a color, the rows do not show the selected blue color. It does show a dot next to the row but the color stays Aqua. this happens only if I have more than one colored row selected.
here is my code in Builder 6.

Any ideas?


void __fastcall TFormUCPFilingDetail::CRDBGrid2DrawColumnCell(
      TObject *Sender, const TRect &Rect, int DataCol, TColumn *Column,
      TGridDrawState State)
{

      if (QryCaliforniaResponses->FieldByName("NoOpenTasks")->AsString == "1")
      {
         if(State.Contains(gdSelected) == true)
         {
             CRDBGrid2->Canvas->Brush->Color = clHotLight;
             CRDBGrid2->Canvas->Font->Color = clWhite;
          }
          else if ( QryCaliforniaResponses->FieldByName("ResDate")->AsString == "" )
          {
             CRDBGrid2->Canvas->Brush->Color = clAqua;
              CRDBGrid2->Canvas->Font->Color = clRed;
          }
          else
          {
             CRDBGrid2->Canvas->Brush->Color = clAqua;
             CRDBGrid2->Canvas->Font->Color = clBlack;
          }

      }
0
Deborah
4/17/2012 2:25:49 PM
embarcadero.cppbuilder.cpp 2803 articles. 0 followers. Follow

5 Replies
975 Views

Similar Articles

[PageSpeed] 9

Deborah wrote:

> when I select multiple rows that have a color, the rows do not show
> the selected blue color. It does show a dot next to the row but the
> color stays Aqua. this happens only if I have more than one colored
> row selected.

You are setting the selected colors only for rows that have NoOpenTasks=1, 
is that what you really want?

--
Remy Lebeau (TeamB)
0
Remy
4/17/2012 8:11:15 PM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Deborah wrote:
> 
> > when I select multiple rows that have a color, the rows do not show
> > the selected blue color. It does show a dot next to the row but the
> > color stays Aqua. this happens only if I have more than one colored
> > row selected.
> 
> You are setting the selected colors only for rows that have NoOpenTasks=1, 
> is that what you really want?
> 
> --
> Remy Lebeau (TeamB)

I want to set the colors for rows that have NoOpenTasks=1 only if they are not selected.
if they are selected, I want them to show the default blue color for selected rows.
0
Deborah
4/19/2012 12:17:11 AM
Deborah wrote:

> I want to set the colors for rows that have NoOpenTasks=1 only if they
> are not selected. if they are selected, I want them to show the
> default blue color for selected rows.

Then I would do it like this:

{code:cpp}
void __fastcall TFormUCPFilingDetail::CRDBGrid2DrawColumnCell(TObject *Sender, 
const TRect &Rect, int DataCol, TColumn *Column, TGridDrawState State)
{
    if (State.Contains(gdSelected) == true)
    {
        CRDBGrid2->Canvas->Brush->Color = clHotLight;
        CRDBGrid2->Canvas->Font->Color = clWhite;
    }
    else if (QryCaliforniaResponses->FieldByName("NoOpenTasks")->AsString 
== "1")
    {
        CRDBGrid2->Canvas->Brush->Color = clAqua;

        if (QryCaliforniaResponses->FieldByName("ResDate")->AsString == "")
            CRDBGrid2->Canvas->Font->Color = clRed;
        else
            CRDBGrid2->Canvas->Font->Color = clBlack;
    }
    else
    {
        ...
    }
    ...
}
{code}

--
Remy Lebeau (TeamB)
0
Remy
4/19/2012 12:42:10 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> Deborah wrote:
> 
> > I want to set the colors for rows that have NoOpenTasks=1 only if they
> > are not selected. if they are selected, I want them to show the
> > default blue color for selected rows.
> 
> Then I would do it like this:
> 
> {code:cpp}
> void __fastcall TFormUCPFilingDetail::CRDBGrid2DrawColumnCell(TObject *Sender, 
> const TRect &Rect, int DataCol, TColumn *Column, TGridDrawState State)
> {
>     if (State.Contains(gdSelected) == true)
>     {
>         CRDBGrid2->Canvas->Brush->Color = clHotLight;
>         CRDBGrid2->Canvas->Font->Color = clWhite;
>     }
>     else if (QryCaliforniaResponses->FieldByName("NoOpenTasks")->AsString 
> == "1")
>     {
>         CRDBGrid2->Canvas->Brush->Color = clAqua;
> 
>         if (QryCaliforniaResponses->FieldByName("ResDate")->AsString == "")
>             CRDBGrid2->Canvas->Font->Color = clRed;
>         else
>             CRDBGrid2->Canvas->Font->Color = clBlack;
>     }
>     else
>     {
>         ...
>     }
>     ...
> }
> {code}
> 
> --
> Remy Lebeau (TeamB)

The problem is that when I select multiple clAqua rows, only the one that has focus gets the blue color. all other selected rows go back to clAqua.
0
Deborah
4/19/2012 12:54:04 AM
Deborah wrote:

> The problem is that when I select multiple clAqua rows, only the one
> that has focus gets the blue color. all other selected rows go back to
> clAqua.

You will have to look at more than just gdSelected by itself, if at all. 
 The underlying DataSet cannot actually have multiple records selected at 
one time.  The grid supports multiple selection, but it are not actually 
a real selection in the true sense of the word.  Multiselection is implemented 
internally using bookmarks.  gdSelected will not be present for non-focused 
records.  One way to work around that is to look up the drawing record in 
the TDBGrid.SelectedRows property to determine if it is "selected" or not, 
rather than rely on gdSelected.

--
Remy Lebeau (TeamB)
0
Remy
4/19/2012 2:00:27 AM
Reply:

Similar Artilces:

Changing Background color of grid row when row checkbox selected
What option should I choose:1) Write java script for this2) Write server code and have grid in UpdatePanel?Not clear what the best guidline would be. I am already using update panel for that grid.Rafal Zikbay.com - Free Classifieds (Search Over 5 mln jobs on Zikbay.com) DNN Direct I guess the best solution should be if I have defined this background color in CSS.. I guess I could use java script to change the class name dynamicly and have that class defined in CSS. Not sure how to do it... Rafal Zikbay.com - Free Classifieds (Search Over 5 mln jobs on Zikbay.com) DNN Direct Here&#...

I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row.
 Hi, Let say I've 4 rows in a table. I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row. Thanks in advance Asghar Ali Mohammed http://www.aliwebdev.com(Web Designer and Developer)Do not forget to "MARK AS ANSWER" on the post that helped you. If you can use Linq, you can use Skip. http://msdn.microsoft.com/en-us/vcsharp/aa336757.aspxThanks, EdMicrosoft MVP - ASP/ASP.NET Hii dear..U can fire the Query select Top(3) from Table1 order by id desc.. "A conclusion is whe...

C#:How to select a row in ListView and change the background color to blue which row is selected
 Hi,This is a part of code,I want to write the method name is select to do what I wanted.I don't know how to judgement which row is selected,and how to change the background color. ------------------------------------------------------------------------------------------------------------------------------ <ItemTemplate>            <tr style="background-color: #FFFBD6;color: #333333;">                <td>   ...

select multiple rows with its row highlighted in GridView
Hello everyone, I'm not using any checkbox or select command to select the row in the GridView, I use the "RowDataBound" event in the GridView for the "onmouseover" click and row select.  That works fine for me but I want to have the functionality to select a multiple rows with its row highlighted and have a row selected count. For example, If I select a row, it hightlights that row and if I select another row, it will do the same thing and have the previous row still highlighted.  I have been looking for a way to implement this but can't find a ...

Selecting the multiple rows in GridView and inserting the selected rows to another Gridview & Performing some operations on it
 Dear All, I have become mad for solving this problem. Please Help me. I have a Gridview bound to a datasource. I inserted the CheckBox Control in Templet to select certain rows. Gridview1 contains some products id & name.I want to insert the selected rows in to second Gridview  and in the second Gridview I need to add two more colums AdvicedQty & AcceptedQty(TextBox Cotrol).The user will select few products in Gridview1 & clicks add which will be added another gridview then in second Gridview he enters the AdviceQty & AcceptedQty.After entering the data he cli...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

DataGrid Rollover Colors, select single, select multiple rows client side
Iam just adding some more lines to JakeJeck's post  http://forums.asp.net/792635/ShowPost.aspx Put this in a class file         public static DataGridItem ApplyRowRollover(DataGridItem item , string MouseOverColor , string MouseOutColor, string MouseClickColor )         {             item.Attributes.Add("onmouseover", "ChangeColorOver(this,'" + MouseOverColor + "','" + MouseClickColor + "');");           ...

Multiple grid rows per Data row in GridView
I have a dataset that is binded to a gridview. The dataset has 5 fields and a description. I want to display 1 row for the 5 short fields and 1 row underneath it for the description. (per record)   For example: ID Name  Surname Field3 Field 4 1   John     Smith      blah    blah     This is the long description for  John Smith spanning 5 cells 2   Peter    Parker     blah    blah     This is t...

After select a row in a grid programmactically, how to bring up the row on the screen?
 I am using ASP.NET 1.1.  I used the following code to select a row programmatically, but the grid is longer than the screen.  I have to scroll down to the row that was selected.  How can I show the row on the screen?For Each strRow As DataGridItem In grdGrid.Items Dim strCells As TableCellCollection = strRow.Cells For Each strCell As TableCell In strCells If InStr(strCell.Text.ToUpper, Request.Params("FromID")) > 0 Then grdGrid.SelectedIndex = strRow.ItemIndex End If Next Next  ...

DataGrid Selected Row Moves To Top Row of Grid????
Hello all, I have a data grid with a link Button column Built in Property Builder (coding in C#). Problem: When a link button is clicked, the row that was selected moves to the top row of the data grid. I need to find a way to simply keep the row where it is and highlight it. I've tried to set the back color of the selectedItem in the Format section of the property builder but nothing happens. If I use a select button highlighting the row as mentioned above works fine but i need to use a link button. If I code the click event of a select button column to response.redirect(&q...

Retrieve data row by row and multiple SELECT statements.
hai to all experts out there,can somebody help me please! I would like to do this sql select statement in vb.net in order to display the output in a gridview. I have a table name TBL_DOC consist of ID,DOC_NO,PIC_FLAG,MPIC1,MPIC2,MPIC3,MPIC4 ,MPIC5 columns. My intention is first i want to retrieve PIC_FLAG column data from all rows in TBL_DOC table  row by row like this: SELECT PIC_FLAG FROM TBL_DOC and then if PIC_FLAG = 'MPIC1' i want to do another select statement like this in the same table: SELECT ID,DOC_NO,PIC_FLAG,MPIC1 FROM TBL_DOC where PIC_FLAG = 'MPIC1...

To get the row index of selected row in grid view
Hi I have a grid view with a column of checkboxes. if I check a checkbox all the remaining checkboxes should be unchecked except the current one.protected void chkHeadCoach_CheckedChanged(object sender, EventArgs e) {foreach (GridViewRow rowitem in grdv.Rows) {CheckBox chkHeadCoach = (CheckBox)(rowitem.FindControl("chkHeadCoach"));if (chkHeadCoach.Checked) {if(rowitem.RowIndex != //row index of the row I checked now) {chkHeadCoach.Checked = false; } } } how can I get the row index of the row I checked now? }Thanks & Regards,Abhiram Reddy Mekha. AbhiramReddyMekh...

Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row.
What is the best way to show a gridview row highlighted once selected and keep it highlighted once the mouse moves over a different row? Thanks, Steve hi,you can use <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" /> plz let me know if i misunderstood you Thanks for your help. One problem; however, is that after the row has been selected and I check the "grid.SelectedIndex" it has a value of -1 and not the index of the row that was selected on the grid. What do you recommend? Thanks, Steve hi, sorry i din...

Adding rows to the grid
I'm trying to add a row to my grid immediately after my EditItem which has been selected. I want the row to span multiple columns. I cannot use a template column with a table in it using rows with varying colspans because I want to be able so sort by my column headers. I've been able to accomplish this by doing the following on ItemDataBound: If e.Item.ItemType = ListItemType.EditItem Then Dim dg As DataGrid = sender Dim tc = New TableCell Dim t As Table Dim di As DataGridItem tc.Controls.Add(New LiteralControl("long description")) tc.ColumnS...

Web resources about - Multiple row selected in a grid with colored rows - embarcadero.cppbuilder.cpp

Code division multiple access - Wikipedia, the free encyclopedia
Code division multiple access ( CDMA ) is a channel access method used by various radio communication technologies. It should not be confused ...

Man stabbed multiple times in street fight
A 23-year-old man suffers multiple stab wounds in a wild street brawl involving up to 100 people.

Facebook Tweaks Power Editor for Users With Multiple Ad Accounts
Facebook rolled out a new feature for its Power Editor that should greatly speed up the process for users with multiple advertising accounts. ...

Rockies trade rumors: Carlos Gonzalez could fit on multiple teams
The oft-injured slugger has two years left on his deal. There are three types of teams in the NL West. Subdividing five teams into three categories ...

Big Pharma bro arrested by federal agents in overnight raid, faces multiple investigations
Big Pharma bro Martin Shkreli gained international notoriety when his company bought the rights to Daraprim—a drug used to treat parasitic infections, ...

Report: Robert Nkemdiche Fell From A 4th-Story Window And Suffered "Multiple Cuts"
Probable top-five NFL draft pick and Ole Miss star Robert Nkemdiche reportedly fell from the 4th floor of a building, and suffered “multiple ...

Insider allegedly hacked lottery software in multiple states
If you use insider knowledge for your own gain, it could land you in hot water... especially if you hacked the computers at your job to get the ...

A Trick Of Gravity Lets Us Observe An Exploding Star Multiple Times
General relativity warps space and time, and astronomers can use that fact to their advantage.

Threats sent to schools in multiple states, some Indiana districts cancel classes
Threats sent to schools in multiple states, some Indiana districts cancel classes

Multiple Airlines Ban Hoverboards Because They Keep Catching on Fire
... three largest airlines in the country—American, Delta, and United— put hoverboards on the no-fly list this week . The decision came after multiple ...

Resources last updated: 12/24/2015 9:15:04 PM