2 Replies - 418 Views - Last Post: 02 October 2012 - 07:51 PM Rate Topic: -----

#1 Theocharis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-October 12

Colouring rows in datagridview

Posted 02 October 2012 - 01:52 PM

i display my query in a datagridview using c#
here it is:



SqlCommand cmd = new SqlCommand(" SELECT RFIDtag, Title, Author, Description, 1 AS QuerySource
FROM Library.dbo.books 
WHERE RFIDtag  in (SELECT tags  FROM Library.dbo.readertags)
Union all
SELECT  RFIDtag, Title, Author, Description, 2 AS QuerySource
FROM Library.dbo.RentedBooks 
WHERE RFIDtag  in (SELECT tags  FROM Library.dbo.readertags); ", UGIcon);

 SqlDataAdapter da1 = new SqlDataAdapter(cmd);

 DataTable ds = new DataTable();
 da1.Fill(ds);
 dataGridView1.DataSource = ds;


mod edit
:code:

how can i display the second query in red?

Is This A Good Question/Topic? 0
  • +

Replies To: Colouring rows in datagridview

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5432
  • View blog
  • Posts: 11,643
  • Joined: 02-June 10

Re: Colouring rows in datagridview

Posted 02 October 2012 - 01:56 PM

WinForms or WPF ?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3452
  • View blog
  • Posts: 10,651
  • Joined: 05-May 12

Re: Colouring rows in datagridview

Posted 02 October 2012 - 07:51 PM

I don't think WPF has a DataGridView. I know that WPF has a DataGrid.

Anyway, the answer for painting a row a custom color is in MSDN:
How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1