|
Hi ,
I want to paint or we can say give the color to the particular row of the datagrid....when....the template column is clicked....so i want to give the backcolor to the entire row at that time....
In datagird I have a one column which is a template column...
Can anybody help me....
Thanks
|
|
|
|
|
The fact that you're mentioning a template column tells me that you're using an ASP.NET DataGrid . If so, this belongs in the ASP.NET forum.
In Windows Forms, you cannot paint an entire row; you can only paint columns by using a custom DataGridColumnStyle implementation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i have a c# app that i am writeing to read a visual foxpro 8 database but when i read the database with c# i lock the table and no one else can use it how to i make it use the file for shared access
thanks
chad aiena
|
|
|
|
|
How are you using it? Are you using ADO.NET to "read" the FoxPro database? There are connection string settings you can use to open the database as a shared database, and last I knew this was the default. Read the FoxPro documentation for more details about the connection string. Anything it documents for its OLE DB provider you can use in the OleDbConnection , and anything for the ODBC driver you can use in the OdbcConnection .
If you're simply reading the file as a stream (and why would you do that? just use the OLE DB provider), then you must specify the appropriate FileShare enumeration member:
FileStream file = new FileStream("file.dbf", FileMode.Open,
FileAccess.Read, FileShare.Read); This allows others to read but not write the file. Read the class documentation for the FileStream in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Please forgive me for being a complete amaeteur about this stuff. I really dont know what I'm doing. The problem I am having is with my scrollable control I am making. Here is the code below for the onPaint.
protected override void OnPaint(PaintEventArgs e)
{
// TODO: Add UserControl1.OnPaint implementation
base.OnPaint (e);
System.Drawing.Graphics g = e.Graphics;
//Draw the underlying background, including alternating row colors.
#region Draw the row backgrounds
//Brushes for the row backgrounds
System.Drawing.SolidBrush backcolor = new SolidBrush( this.RowBackgroundColor );
System.Drawing.SolidBrush altbackcolor = new SolidBrush( this.RowAlternatingBackgroundColor );
//Now draw the rows backgrounds.
float startpos = 0;
bool alternate = true;
int controlwidth = this.ClientRectangle.Width;
while ( startpos < this.ClientRectangle.Height )
{
if( alternate == true )
{
g.FillRectangle( backcolor, 0, startpos, controlwidth, this.RowHeight );
alternate = false;
}
else
{
g.FillRectangle( altbackcolor, 0, startpos, controlwidth, this.RowHeight );
alternate = true;
}
startpos += this.RowHeight;
}
backcolor.Dispose();
altbackcolor.Dispose();
#endregion
}
My problem is this. I put this control on a blank form and then put a listbox inside this control and made the listbox longer than the control so scoll bars would appear. When I run the form everything appears normal at first. However, once I scroll, the background, that should be just alternating colors does not get updated. One color will just take up the rest of the space on the bottom of the control. I hope that makes sense, it's kind of hard to explain. Any help would be appreciated. Thanks
Paul Rogero
|
|
|
|
|
Either create a bitmap (you can save it as a BMP (large), JPEG (small), or PNG (medium, but nice), or other formats but I recommend those. Then assign that to the BackgroundImage property.
Or, make sure you update your code according to the scroll position. When you paint, you can only paint in the client area (i.e., the visible portion of the code). Scrolling the control will not automatically do this for you. You have to code your painting handler to take the correct scroll position into account. Use the AutoScrollPosition (defined by ScrollableControl , inheritted by any derivative like UserControl and Panel ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Paul,
Below is your OnPaint function. I changed it to fix your problem (or what I believe you are saying is your problem) The fix was only two lines and they have //********** at the end of them so they stand out.
<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint (e); <br />
<br />
System.Drawing.Graphics g = e.Graphics;<br />
<br />
#region Draw the row backgrounds<br />
System.Drawing.SolidBrush backcolor = new SolidBrush( this.RowBackgroundColor );<br />
System.Drawing.SolidBrush altbackcolor = new SolidBrush( this.RowAlternatingBackgroundColor );<br />
float startpos = AutoScrollPosition.Y;
bool alternate = true;<br />
int controlwidth = this.ClientRectangle.Width;<br />
while ( startpos < this.ClientRectangle.Height - AutoScrollPosition.Y )
{<br />
if( alternate == true )<br />
{<br />
g.FillRectangle( backcolor, 0, startpos, controlwidth, this.RowHeight );<br />
alternate = false;<br />
}<br />
else<br />
{<br />
g.FillRectangle( altbackcolor, 0, startpos, controlwidth, this.RowHeight );<br />
alternate = true;<br />
}<br />
startpos += this.RowHeight;<br />
}<br />
backcolor.Dispose();<br />
altbackcolor.Dispose();<br />
#endregion<br />
}<br />
Hope this helps!!
Karl Baum
CEO of KGB Technologies
Specializing in custom software development.
|
|
|
|
|
I wrote my first multi-threaded app in C# and I am having a bit of a problem. Everything works perfectly when the app is run on a users local machine. The problem comes into play when a person runs the app from our network.
I'll try to explain this as best as I can, I have a class which creates a member varible of a thread, then starts this thread. The thread goes to a member function in the same class where a new class is created and I call the "worker" member function of this new class.
This function enumerates some processes and deletes and renames a file. Basiclly when this is run from the network it hangs/crashes with a security exception when calling the new class member function. The only exception message I get back is "Request failed." that's it... I also get a secuity exception when I call Application.Exit() (Which is the last line before main() ends)
<br />
IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"<br />
version="1"<br />
Flags="UnmanagedCode"<br />
Strage stuff, cause none of these problems happen when working off a local copy on my HD. One interesting note, if I comment out the code in my "worker" class member function. I don't get the Request failed.
Any idea what all this is about?? Cause I am so confused!!
|
|
|
|
|
Working in a local environment (where you also are running as an administrator of your machine) creates a false sense of ... well ... security in your code. No pun intended.
Some things to check out:
Did you establish security permissions in your project ?
Can NT security be part of the problem? Do you have read rights where
you really need read/write rights when running on the server?
If all of the rights look alright, then did you set your security
provider correctly? Default for SecurityProvider is GeneralProvider.
You need to specifically change it to have a WindowsProvider as your
security.
______________________________
The Tao gave birth to machine language.
Machine language gave birth to the assembler.
The assembler gave birth to ten thousand languages.
Each language has its purpose, however humble.
Each language expresses the Yin and Yang of software.
Each language has its place within the Tao.
Beauty exists because we give a name to C#.
Bad exists because we give a name to COBOL.
|
|
|
|
|
His project and NT security have nothing to do with it. It's .NET Code Access Security, which is a feature of the CLR.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The Common Language Runtime (CLR) features Code Access Security - a sandbox environment for .NET, if you will. By default, applications executed from the network (or that use network resources) run without FullTrust permissions. They are limited in what they can do, and local file access is restricted, among many other things.
I suggest you first read Understanding .NET Code Access Security[^]. You need to either change the Intranet permission set (not recommended), or create a new CodeGroup that uses a membership condition that will match up with your host or assembly evidence that the CLR would grab (like using a Url membership condition with "file://MYNETSERVER/SOMESHARE/*"). Grant that either FullTrust permissions (not recommended; do things right) or the necessary permissions to run.
To help administrators know what permissions your code requires, you should attribute your assembly with certain permission requirements (assembly-level attributes). You should also be mindful that your code may not be granted optional permissions and should check for SecurityException s accordingly (by either catching potential cases, or asserting the permission to see if you can perform a certain action).
For that, read Securing Applications[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
or create a new CodeGroup that uses a membership condition that will match up with your host or assembly evidence that the CLR would grab (like using a Url membership condition with "file://MYNETSERVER/SOMESHARE/*"). Grant that either FullTrust permissions (not recommended; do things right) or the necessary permissions to run.
Yikes, I've read through the article a few times and still don't quite see what you mean by this. Some of these follow-up questions are probably still due to my misunterstanding but here they are none the less.
Can I just grant the program the "fulltrust" or permissions it needs no matter where it's being run from? Cause the file could be run from anywhere on our network. Not a specific location, I just can't seem to figure out how to do this? Is it an assembly directive?
It seems like creating a codegroup is just for the local machine and not everyone which is bad for 100+ people that would be running this.
P.S. I added:
[assembly:FileIOPermission(SecurityAction.RequestMinimum, Write="C:\\")]
To at least throw an exception when it can't do what it needs to do, I just have no clue how to handle the exception. (Where does it throw to?)
This is really wild stuff, Thanks for taking the time to help explain it.
|
|
|
|
|
An application can only tell the CLR what it needs to run. It can't grant itself permissions; that would defeat the purpose. Do you trust someone just because they say they're trustworthy? I certainly don't.
If you use an assembly-level permission attribute, the assembly is not even executed so you can't handle an exception (unless you're a different assembly trying to use a type defined in that assembly, when it's loaded for the first itme - you really have to understand how the CLR works).
You can grant your assembly or assemblies FullTrust permission (again, that's a big cop-out and not a very good idea) if you use assembly evidence to match up with membership conditions for a code group. Assembly evidence is strong name identity evidence and publisher (x.509) evidence. If you add a CodeGroup using either of those membership conditions, then your assembly will be granted whatever permission set you choose. If you use host-based evidence like URLs or site, then an assembly matching that evidence will be granted those permissions.
A codegroup is installed into a machine's policy, yes, which is why you have to install it onto all machines. This is no different that ActiveX security (what little there is) policies and Java sandbox policies. This can be distributed through Windows Installer packages, batch files, start-up scripts, whatever. Distributing a policy is not hard if you no what you're doing.
Don't just read the article; read the other links I gave you as well. The article here on CodeProject explains Code Access Security, but there's more information about setting up code groups and why.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
about Ado.net.When get data from database, use dataset or datareader which is faster?
|
|
|
|
|
A DataSet is used to store data not extract it from the database. However the operation to fill a DataSet uses the DataReader to get the information from the database. The DataReader is a Read-Only Forward-Only mechanism to get information out of the database.
The two are not directly comparable, it depends on what you want to do with the data. However, if all you want to do is read the data quickly then the DataReader is your best choice.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
I found out when loading some images into imagelist,then using these images in Application, as a result these images's quality are very bad.but I using Image.FormFile(strFilename), these are normal.Why? do i should do it?
|
|
|
|
|
Is the "ColorDepth " property of your imagelist set to "Depth32Bit "? If not, then set it to that value and see if that fixes the problem.
Happy Programming and God Bless!
"Your coding practices might be buggy, but your code is always right."
Internet::WWW::CodeProject::bneacetp
|
|
|
|
|
The ImageList control, not the .NET class, but the ImageList control it wraps, has a bunch of problems. I would suggest you try to avoid using the control if you can.
But, the problems depends on what other controls your using the ImageList with, such as a TreeView getting it images from an Imagelist, and/or the types of file your loading into the ImageList. For instance, the Imagelist has problems with certain types of images using an alpha channel.
So you'll have to be a bit more specific about the problem so we can suggest a fix or workaround. What kind of problems are you having specifically? Do they involve using the ImageList supplying images to other controls?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm not very experienced in .NET Remoting technology. I wrote some simple demos involving that aspect.but I found the client side must reference the server side so that the Activator can create the stub of the server object. when we distribute the application, we have to place a copy of server assembly along with client side.
A copy of server object along with client means Remoting? I think it should not like that, but I don't quite understand.
Then in general, what's the correct way to develope and distribute a .NET remoting application?
Thanks.
|
|
|
|
|
Yes, that's right. You have to reference the library that implements the server objects from the client side. I think it is similar to COM+ (or DCOM) where you have to install the type library on the client machine.
I hate this, too, that's why I prefer web services to remoting. However, I am no expert on .NET remoting.
My articles and software tools
|
|
|
|
|
Then you might want to do it right. You do not have to reference the server code, only the interface that the Remoting object implements. So, either define the interface that the server object implements in a shared assembly, or use soapsuds.exe to create a client-side proxy.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
You do not have to reference the server code, only the interface that the Remoting object implements.
But that is still a pain, don't you agree? With web service, I only care about the interface of the web method I am calling. Also, I can use web methods in non .NET programs or non windows platforms.
My articles and software tools
|
|
|
|
|
I'm afraid I don't understand the point you're trying to make. Personally, I don't think it's hard at all - in fact, I'd rather link against the same interface for type safety and resolution. But the original question doesn't deal with ease, only how to do what the poster was wanting.
As far as a shared interface between web services and remoting, it's really don't different. The biggest difference is that with web services you can create a similar interface, where with .NET remoting the Type of the interface almost always has to be the same (there are tricks around this).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
I'm afraid I don't understand the point you're trying to make. Personally, I don't think it's hard at all - in fact, I'd rather link against the same interface for type safety and resolution. But the original question doesn't deal with ease, only how to do what the poster was wanting.
You are right, it is not hard and my point (if I have one) is not very closely related to the original question.
However, in the original post the poster does show his "frustration" that he has to deploy a server dll on the client side. This server dll may contain only the interface not the implementation details, as pointed out by you and others. My point is, using web service you don't have to do this and there are other advantages of using a web service.
[Edit]
Here is an example to demonstrate the "pain" I am talking about. Supppose the remote object has 3 methods and it is used by mutiple client applications running on remote machines.
The clients and the server are closely tied by the shared dll that contains the interface of the remote object. If you add another method to the remote object which is needed by only one new client, then all the clients have to be recompiled with the new version of the shared dll.
[/Edit]
My articles and software tools
|
|
|
|
|
Xiangyang is wrong. You don't have to reference the implementation dll. Check out an example of how to use a proxy share dll here.
http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=RemoteObject
|
|
|
|
|