Results 1 to 3 of 3

Thread: changing text in a selected row in a datagrid

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    changing text in a selected row in a datagrid

    Hello,

    I have a datagrid with books, when the book is overdue i want it to change the text to Red. A for has been used to go through each row (works fine). But when it comes to a book that is overdue, l want it to change the text to red. I have tired using the code below, but does not work.

    <code>if ( dateDue < todaysDate )
    {
    grdBookOnLoan.Select(i); //i For loop counter
    grdBookOnLoan.ForeColor = Color.Red;
    grdBookOnLoan.UnSelect(i);
    }</code>

    Thanks in advance,

    Steve
    steve

  2. #2
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    Re: changing text in a selected row in a datagrid

    Quote Originally Posted by steve_rm
    Hello,

    I have a datagrid with books, when the book is overdue i want it to change the text to Red. A for has been used to go through each row (works fine). But when it comes to a book that is overdue, l want it to change the text to red. I have tired using the code below, but does not work.

    <code>if ( dateDue < todaysDate )
    {
    grdBookOnLoan.Select(i); //i For loop counter
    grdBookOnLoan.ForeColor = Color.Red;
    grdBookOnLoan.UnSelect(i);
    }</code>

    Thanks in advance,

    Steve
    Steve,

    No offense to you, but if you are looping through each row, you're doing it the wrong way. Your db backend (if it's sql) should allow you to return rows based on specific criteria, that criteria being overdue books or what not. When you have the resultant of returned rows you know these are the "overdue" entries. So why are you ever looping through every row to make some text red ?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Re: changing text in a selected row in a datagrid

    Thanks for the reply.

    What my system does is, it lists all the books that the user has booked out, and displays only the rows in red where they are overdue. I have a loop that checks if the books are overdue (this works fine), but the problem is, when it finds a row with an overdue book, l don't know how to make the text in that row red. This is so that the admin staff can see more clearly the books that the user has and the ones that are overdue.

    Hope this make everything more understandable.

    I thought this would be an easy problem to solve.


    Thanks for your help in advance,

    Steve
    steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width