|
Hi ! I found many snippets (samples) of code on the web but every one is for C# with ASP.NET or written in VB.NET. My application is not WEB based but a normal Windows Form with a dataGrid (windows application). Sometime I want to change the background and foreground color of a row depending of some condition (NOT the SELECTED row). I understand the idea of using the databinding event (which is supposed to be throw at each Rows.Add()) but I still have problem with my code. Maybe I don`t really know how to use event. The other idea is to modify the Paint function (I am not very confident with this).
Can somebody show me a sample !!!
Thank you very much !
Danny Gilbert
Montréal, Canada
|
|
|
|
|
Hai,
You can actually inherit from DataGridColumnStyle and override the paint method where you check the condition and set the backbrush color accordingly. Just make sure all of your column styles has this code so the each column in row has same color.
Hope this helps
Thanks,
VPMahank
Here is a sample
public class DataGridTextBoxColumnCustom : DataGridTextBoxColumn
{
///
/// Invalidates the display of this column, causing it to be repainted.
///
public void Repaint()
{
Invalidate();
}
protected SolidBrush _BackBrush = new SolidBrush(Color.White);
protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
{
Brush bkBr = backBrush;
try
{
// you condition check logic
if( your condition == true)
{ backBrush = new SolidBrush(some color);
}
else if ()
backBrush = new SolidBrush(some color);
else
backBrush = new SolidBrush(some color);
}
catch (Exception exc)
{
} // ignore
finally
{
base.Paint(g, bounds, source, rowNum, backBrush, foreBrush, alignToRight); }
}
|
|
|
|
|
Thank you ! Now I understand more things. I do something like your proposal for any control... overriding the paint method for any control.
Thanks again !
Danny Gilbert
Montréal, Canada
|
|
|
|
|
Using this example I can set a row to a specific color based on its content, but it doesn't work if I sort the datagrid or use a DataView.RowFilter. Does anyone know how to make it work?
To clarify, in the paint method I get the number of the row of the datatable, so if row #2 has a value that sets the background to red, row #2 in the datagrid becomes red. But if I use a RowFilter so that row #1 of the datatable isn't shown in the datagrid, it is still row #2 of the datagrid that is red even though the content has changed and the row that should be red now is row #2.
/Cesa
|
|
|
|
|
Can anyone tell me how I can download my mail in Outlook 2003 using code. All the accounts in Outlook are configured and all I wish to accomplish is that when a user clicks a button on my form, the Email Send/Receive process in outlook is invoked and it closes Outlook when the emails have been downloaded.
|
|
|
|
|
I haven't tried this myself, so I can't give you specific instructions, but you could try using the Outlook Express Mail Object (msoe.dll).
From the VS toolbox, you can right click, and select Add/Remove Items. Then click on the COM Components tab, and look for the Outlook Express Mail Object, and check the box. This will add the component to your toolbox.
From here, search the web for more information on this object, and perhaps play around with it for a while.
Have fun. Good luck.
Roy.
|
|
|
|
|
Does anyone know how to access custom file properties... the properties you see in the "custom" tab in Windows XP when you right click and show file properties?
Just need something to get me pointed in the right direction.
Thank you in advance.
Jerry Holmes
jholmes@verdigre.com
|
|
|
|
|
|
Hello!
I am trying to do some P/Invoke and the native library returns a structure. How must I declare this in C#?
Assume this (only as example):
I defined a structure
[StructLayout(LayoutKind.Sequential)]
public struct ColorWithUUID
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] uuid;
public UInt32 argb;
}
and the native function looks like:
COLORWITHUUID* GetColorWithUUID(DWORD dwIndex);
So the native function creates a COLORWITHUUID object and returns the pointer to it. How would the DllImport in C# for this function look like? How can I convert the pointer to the ColorWithUUID structure?
Many thanks in advance and best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
[DllImport("whatever.dll")]
IntPtr GetColorWithUUID(uint index);
IntPtr structPtr = GetColorWithUUID(index);
ColorWithUUID c = (ColorWithUUID)Marshal.PtrToStructure(structPtr, typeof(ColorWithUUID));
<pre>
-- modified at 14:32 Wednesday 4th January, 2006
|
|
|
|
|
Works like a dream, thank you very much!
Best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hello coders,
I am using VS.NET, Application type is SmartDevice. In this form I placed the webBrowser control. I added one context menu with 3 MenuItems.
ContextMenu Implementation code is properly is taken, one more problem with webbrowser is not having
.ContextMenu Property. So I am taken
this.ConctextMenu = this.mycontextmenu1
my Problem is when running this application browser default contextMenu is displaying instead of my context menu.
any ideas??
regards
GV Ramana
-- modified at 13:25 Wednesday 4th January, 2006
|
|
|
|
|
Are you handling the HTMLDocumentEvents2_oncontextmenuEventHandler event?
If so, I believe you need to set eobj.returnValue to false and show your own custom menu.
"Patriotism is the first refuge of a patriot."
|
|
|
|
|
I am not yet get, My application type is SmartDevice Application in VS 2005.
HTMLDocumentEvents2_oncontextmenuEventHandler event is ?????
regards
GV Ramana
|
|
|
|
|
The webBrowser control has an api with includes a document class which allows you to connect to various event handlers. I have not used it in a SmartDevice application, so I don't know what the limitations might be.
This [^] should give you an idea of how it is organized.
"Patriotism is the first refuge of a patriot."
|
|
|
|
|
Hi
I am using server.transfer("webform2.aspx") to open page webform2.aspx and displaying some information on this page.
Is their any way I can open this new page in a seperate browser window ? I dont want to use javascript.
Thanks
|
|
|
|
|
You can't control from the server side where the page is being opened. That is already decided when the request is sent to the server.
There are two ways that you can use to control where the page will be opened, by using target or javascript.
---
b { font-weight: normal; }
|
|
|
|
|
I think I will go ahead with javascript
|
|
|
|
|
Need your help guys, I've been trying to make a program like ProcessGuard and Sanctuary. This product prevents execution of any program that does not appear on the list of software that is allowed to run on a particular machine. I have made some research about it and I found out that you have to go to kernel-mode and hook its API on process creation(CreateProcess). But I failed to utilize the use of kernel32.dll or ntdll.dll. Is there someone here where that could me give some tips where to start, provide the basics of Windows API process hooking in C# or even better provide a working C# source code. Thanks in advance...
bryandel3@yahoo.com
http://www.bryandel.net/
-- modified at 5:48 Thursday 5th January, 2006
|
|
|
|
|
|
I have already read it anyway thanks. Pls I need a guide in C#
|
|
|
|
|
C# is not appropriate for this. It is designed for making user mode applications only.
I have taken a vow of poverty. If you want to really piss me off, send me money.
|
|
|
|
|
But is it possible?
About the money, I'm sorry but I can't send any. I'm still a student.
And I might make this program as my thesis. But still thanks for the offer.
|
|
|
|
|
I dont think it is possible but I could be wrong. If you use c# then you have a dependancy on the Dot Net runtime. I dont beleive that it is currently possible to use this with in kernal mode. I suggest you have a look around the "sys internals" web site
I have taken a vow of poverty. If you want to really piss me off, send me money.
|
|
|
|
|
Hello bryan,
first include in your class the System.Runtime.InteropServices
using System.Runtime.InteropServices;
Then is simple:
[DllImport ("user32.dll")]
public static extern long DestroyWindow (long hWnd);
Now use this site http://custom.programming-in.net/ to find out the dll of your function and then import it!!
If i din't got your question, and i'm completely off, oups sorry, give some more details
Happy new year to all!!
GanDad
|
|
|
|