Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 75 Time: 13:41 - Jun 14, 2007  

webmavin

how to give custom gradient effect background to datagridview header in windows .net2.0?

how to give custom gradient effect background to datagridview header in windows .net2.0?

Answer Discussion
Tutorials

 

admin

Date:: Aug 22, 2007

Time:: 13:25

webmavin, did you get your question solved?

If you did then please close this question and distribute the points. If you found the solution on your own, we would be very happy if you could explain it here for the sake other users having the same problem.

If you didn't get a solution to your problem, please leave a comment here to let the experts know that you're still looking for an answer.

Thanks,
The Quomon Admin Team

webmavin

Date:: Aug 23, 2007

Time:: 02:00

Nope, i did not find an efficient way yet to give a custom gradient effect background to the datagridview header.

prashanth.guru

Date:: Oct 18, 2007

Time:: 06:19

Depends on which cells you want to fill with gradient brush. Have a look at

:

DataGridView.RowPrePaint and / or
DataGridView.CellPainting

The following code applies a gradient background to each cell within the
first column that isn't selected:

dataGridView1.CellPainting +=
new DataGridViewCellPaintingEventHandler(dataGridView1_CellPainting);

void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if ((e.ColumnIndex==0) && (e.RowIndex != -1) &&
(e.State & DataGridViewElementStates.Selected)!=
DataGridViewElementStates.Selected)
{
// fill gradient background
Brush gradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(
e.CellBounds, Color.Blue, Color.BlueViolet,
System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal);
e.Graphics.FillRectangle(gradientBrush, e.CellBounds);
backbrush.Dispose();

// paint rest of cell
e.Paint(e.CellBounds, DataGridViewPaintParts.Border |
DataGridViewPaintParts.ContentForeground);
e.Handled = true;
}
}

----------------------------------- OR -----------------------------------

private void gridChannel_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
bool isHandled = false;
if (e.RowIndex >= 0 && e.ColumnIndex == 2)
{
if (gridChannel[e.ColumnIndex, e.RowIndex].Value != null &&
IrcBase.MDIParentForm.AppSettings.ProfileWordWatchSettingsCol.CheckForMatch(gri
dChannel[e.ColumnIndex,
e.RowIndex].Value.ToString()))
{
System.Drawing.Drawing2D.LinearGradientBrush lBrush =
new System.Drawing.Drawing2D.LinearGradientBrush(e.CellBounds,
e.CellStyle.BackColor,
IrcBase.MDIParentForm.AppSettings.ProfileMatchCellColor,
System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
e.Graphics.FillRectangle(lBrush, e.CellBounds);
lBrush.Dispose();
e.Paint(e.CellBounds, DataGridViewPaintParts.Border |
DataGridViewPaintParts.ContentBackground |
DataGridViewPaintParts.ContentForeground | DataGridViewPaintParts.ErrorIcon

| DataGridViewPaintParts.Focus);

e.Handled = true;
isHandled = true;

}

}
if (!isHandled)
{
e.Handled = false;
}


Thanks,
Prash

admin

Date:: Mar 24, 2009

Time:: 09:46

The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.

The Quomon Team

Question Answered

This question has been closed, and points have been rewarded to the following experts:


prashanth.guru: 75

You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No tutorials have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es