|
-
Oct 7th, 2009, 02:41 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Change Cell Color + GridView
I want to change the value & its backcolor of cell.
On Button1_Click,I m adding records to the Gridview.
On Button3_Click,I want to chnage the value of cell & its backcolor.
Suppose two Rows & two columns are there in Grdiview
1 10
2 20
Suppose I want to change the value of item(Row=2,Colomn=2) to 100. I change the value but i m not ablt to change the backcolor.Can somebody tell me?
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim row0 As String() = {TextBox1.Text, TextBox2.Text}
DataGridView1.Rows.Add(row0)
row0 = Nothing
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
DataGridView1.Item(1, 1).Value = 100
'What to write to chnage the cell color
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
-
Oct 7th, 2009, 03:01 AM
#2
Re: Change Cell Color + GridView
Code:
dataGridView1.Rows[0].Cells[0].Style.BackColor = Color.Red;
Please mark you thread resolved using the Thread Tools as shown
-
Oct 7th, 2009, 03:11 AM
#3
Thread Starter
Hyperactive Member
Re: [RESOLVED] Change Cell Color + GridView
-
Oct 7th, 2009, 03:13 AM
#4
Thread Starter
Hyperactive Member
Re: [RESOLVED] Change Cell Color + GridView
Tell me one thing more that is it possible to change all colors of row of Griview widout using any for loop( For RowNum = 0 To DataGridView1.RowCount - 2)
-
Oct 7th, 2009, 03:41 AM
#5
Re: [RESOLVED] Change Cell Color + GridView
Are you looking for this one ?
Code:
dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Red;
Please mark you thread resolved using the Thread Tools as shown
-
Oct 7th, 2009, 03:46 AM
#6
Thread Starter
Hyperactive Member
Re: [RESOLVED] Change Cell Color + GridView
Suppose there are 10 rows in Gridview,Is it poss to chnage all the 10 rows backcolor at once,Without uisng any Gridview Row loop
-
Oct 7th, 2009, 04:06 AM
#7
Re: [RESOLVED] Change Cell Color + GridView
Here it is
Code:
dataGridView1.DefaultCellStyle.BackColor = Color.Red;
Please mark you thread resolved using the Thread Tools as shown
-
Oct 7th, 2009, 04:08 AM
#8
Thread Starter
Hyperactive Member
Re: [RESOLVED] Change Cell Color + GridView
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|