473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Datagrid Readonly Background Color Override?

Hi All;

I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have
customized it for a wider row. I reposition the DrawString method so the
text is centered vertically in the row.

My problem now is that on ReadOnly cells the shaded background is not at the
top of the cell. I adjust the rectangle Height so that the shading does not
drop into the next row.

Is there an override that I can write to reposition the shaded background?

Thanks.
Nov 21 '05 #1
4 1944
Hi,

In the paint procedure I use the brushes sent it to draw. You can
replace the foreBrush and backBrush with what ever you want to customize its
look. Have fun with it.

Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics,
ByVal bounds As System.Drawing.Rectangle, ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush,
ByVal alignToRight As Boolean)

'clear the cell

g.FillRectangle(backBrush, bounds) ' Could try g.FillRectangle(Brushes.Gray,
bounds)

'draw the value

Dim s As String = Me.GetColumnValueAtRow([source], rowNum).ToString()

Dim r As Rectangle = bounds

r.Inflate(0, -1)

g.DrawString(s, MyBase.TextBox.Font, foreBrush, RectangleF.op_Implicit(r), _

mDrawTxt)

End Sub
Here is a link to some more examples of column styles.
http://www.onteorasoftware.com/downl...redcolumns.zip
Ken
------------------------
"John Smith" <so*****@microsoft.com> wrote in message
news:1fjae.1109512$8l.266337@pd7tw1no...
Hi All;

I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have
customized it for a wider row. I reposition the DrawString method so the
text is centered vertically in the row.

My problem now is that on ReadOnly cells the shaded background is not at the
top of the cell. I adjust the rectangle Height so that the shading does not
drop into the next row.

Is there an override that I can write to reposition the shaded background?

Thanks.

Nov 21 '05 #2
Thanks Ken...but...

what I really need is to change the background color and the rectangle
bounds when the cell has focus.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OX**************@TK2MSFTNGP14.phx.gbl...
Hi,

In the paint procedure I use the brushes sent it to draw. You can
replace the foreBrush and backBrush with what ever you want to customize its look. Have fun with it.

Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean)

'clear the cell

g.FillRectangle(backBrush, bounds) ' Could try g.FillRectangle(Brushes.Gray, bounds)

'draw the value

Dim s As String = Me.GetColumnValueAtRow([source], rowNum).ToString()

Dim r As Rectangle = bounds

r.Inflate(0, -1)

g.DrawString(s, MyBase.TextBox.Font, foreBrush, RectangleF.op_Implicit(r), _
mDrawTxt)

End Sub
Here is a link to some more examples of column styles.
http://www.onteorasoftware.com/downl...redcolumns.zip
Ken
------------------------
"John Smith" <so*****@microsoft.com> wrote in message
news:1fjae.1109512$8l.266337@pd7tw1no...
Hi All;

I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have
customized it for a wider row. I reposition the DrawString method so the
text is centered vertically in the row.

My problem now is that on ReadOnly cells the shaded background is not at the top of the cell. I adjust the rectangle Height so that the shading does not drop into the next row.

Is there an override that I can write to reposition the shaded background?

Thanks.

Nov 21 '05 #3
Hi,

I am not sure how a cell can get focus if it is readonly.

Ken
---------------------------
"John Smith" <so*****@microsoft.com> wrote in message
news:cRvae.1117332$8l.425982@pd7tw1no...
Thanks Ken...but...

what I really need is to change the background color and the rectangle
bounds when the cell has focus.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OX**************@TK2MSFTNGP14.phx.gbl...
Hi,

In the paint procedure I use the brushes sent it to draw. You can
replace the foreBrush and backBrush with what ever you want to customize its look. Have fun with it.

Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
backBrush As System.Drawing.Brush, ByVal foreBrush As System.Drawing.Brush, ByVal alignToRight As Boolean)

'clear the cell

g.FillRectangle(backBrush, bounds) ' Could try g.FillRectangle(Brushes.Gray, bounds)

'draw the value

Dim s As String = Me.GetColumnValueAtRow([source], rowNum).ToString()

Dim r As Rectangle = bounds

r.Inflate(0, -1)

g.DrawString(s, MyBase.TextBox.Font, foreBrush, RectangleF.op_Implicit(r), _
mDrawTxt)

End Sub
Here is a link to some more examples of column styles.
http://www.onteorasoftware.com/downl...redcolumns.zip
Ken
------------------------
"John Smith" <so*****@microsoft.com> wrote in message
news:1fjae.1109512$8l.266337@pd7tw1no...
Hi All;

I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have
customized it for a wider row. I reposition the DrawString method so the
text is centered vertically in the row.

My problem now is that on ReadOnly cells the shaded background is not at the top of the cell. I adjust the rectangle Height so that the shading does not drop into the next row.

Is there an override that I can write to reposition the shaded background?

Thanks.


Nov 21 '05 #4
Well...um...maybe I am calling what happens the wrong term.

This is how the cell is set to ReadOnly.

Me.IndividPayDataGridDue.ReadOnly = True
Once I populate the DataGrid with data. You can click on the cell. The text
background becomes blue and the unused portion of the cell becomes shaded.
The text in the cell cannot be changed.

Is this getting Focus, becoming Active or something else? Are both terms
relatively the same?

Anyway, I fix the problem by reducing the bounds.Height in the Edit
Override. Now the only shaded part is the unused portion of the TextBox and
not the entire cell.

Thanks for all your help!!!
I really appreciate it!!


"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:eh*************@TK2MSFTNGP10.phx.gbl...
Hi,

I am not sure how a cell can get focus if it is readonly.

Ken
---------------------------
"John Smith" <so*****@microsoft.com> wrote in message
news:cRvae.1117332$8l.425982@pd7tw1no...
Thanks Ken...but...

what I really need is to change the background color and the rectangle
bounds when the cell has focus.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OX**************@TK2MSFTNGP14.phx.gbl...
Hi,

In the paint procedure I use the brushes sent it to draw. You can replace the foreBrush and backBrush with what ever you want to customize its
look. Have fun with it.

Protected Overloads Overrides Sub Paint(ByVal g As

System.Drawing.Graphics,
ByVal bounds As System.Drawing.Rectangle, ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal
backBrush As System.Drawing.Brush, ByVal foreBrush As

System.Drawing.Brush,
ByVal alignToRight As Boolean)

'clear the cell

g.FillRectangle(backBrush, bounds) ' Could try

g.FillRectangle(Brushes.Gray,
bounds)

'draw the value

Dim s As String = Me.GetColumnValueAtRow([source], rowNum).ToString()

Dim r As Rectangle = bounds

r.Inflate(0, -1)

g.DrawString(s, MyBase.TextBox.Font, foreBrush, RectangleF.op_Implicit(r), _

mDrawTxt)

End Sub
Here is a link to some more examples of column styles.
http://www.onteorasoftware.com/downl...redcolumns.zip
Ken
------------------------
"John Smith" <so*****@microsoft.com> wrote in message
news:1fjae.1109512$8l.266337@pd7tw1no...
Hi All;

I am using the HeaderAndDataAlignColumn class from Ken Tucker. I have
customized it for a wider row. I reposition the DrawString method so the
text is centered vertically in the row.

My problem now is that on ReadOnly cells the shaded background is not at

the
top of the cell. I adjust the rectangle Height so that the shading does

not
drop into the next row.

Is there an override that I can write to reposition the shaded

background?
Thanks.


Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
3
by: Zürcher See | last post by:
Someone has implemented a Datagrid Button for the Windows.Form?
0
by: Rudolph Araujo | last post by:
Hi, I needed to build a data grid in which the first column has hyperlinks rather than simple text. I found the following code on this newsgroup and it works fine except for one problem. When I...
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
2
by: Will | last post by:
Hi I've been looking a way to put buttons in a column, but almost every example is for WebForms and I need it for WinForms... I found a way for doing it, with the DataGridColumnStyle class,...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
0
by: Mauro | last post by:
Hi, I need a big help to resolve this problem. I need to put a usercontrol in a datagrid: this control check if the code inserted is present in a archive and if not return a error message. (In...
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.