|
Yes, but you'll need to extend the DataGridColumnStyle - or the DataGridTextBoxColumn and DataGridBoolColumn to avoid implementing all their functionality - and add a BackColor (for example - could be named whatever you want) property. In the override for Edit , set the BackColor and then call base.Edit . The the overrides for Abort and Commit , reset the BackColor to the default and again call the method on the base class. In the Paint override, use the provided Graphics object to paint the background using the BackColor value on your class then call base.Paint .
See Changing the background color of cells in a DataGrid[^] for an example of conditional painting like this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have got a DataGrid (with GridTextBoxes..) and I need that whenever the user types in a certain column some value that is not correct to clear that cell..
DataGridTextBoxColumn _datagridtextBox = (DataGridTextBoxColumn) MyDataGrid.TableStyles[0].GridColumnStyles[3];
datagridtextBox.TextBox.... += new System....EventHandler(this.Execute_This);
What code Event, EventHandler and method Execute_This should write...
Thank YOUUU..
|
|
|
|
|
You don't want to use TextChanged as so many try, because that gets fired AFTER the text is committed to the TextBox and hence to the data source. Instead, handle KeyDown and if they enter an invalid value, you could event simply cancel the key event (set KeyEventArgs.Handled to true ). If not, just set TextBox.Text to an empty string or whatever else you want to do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi.
I have a class that read a file, that's ok. How can I pass the data that I readed to the Form class?. Now I have implemented a property field in the class that holds the handle of the control and that works, but I don't want this solution and neither to pass a control reference to the class.
There's another way to fix this?.
Thank you.
Demian.
|
|
|
|
|
You can make a custom construcotr, and pass that data throuht that construcotor ...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
When you need to update references (like an instance of a Form ), you'll need a reference to that object. There's simply no other way. How you pass/access that reference is up to you. Passing a reference (not handle, which is something entirely different) to the class that reads the data in order to assign the data to that reference is one good way of doing it. Another would be to have your Form derivative use that class that reads the data and fill-in its child controls using that data, which is a more common approach.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you very much Heath.
Regards.
Demian.
|
|
|
|
|
Hi,
Let's have a dream. I have a class with some properties, here a sample :
public class TestClass<br />
{<br />
private int myint;<br />
private string mystring = "";<br />
<br />
public TestClass() { }<br />
<br />
[DefaultValue(100)]<br />
public int IntProp<br />
{<br />
get { return myint; }<br />
set { myint = value; }<br />
}<br />
<br />
[DefaultValue("idea")]<br />
public string StringProp<br />
{<br />
get { return mystring ; }<br />
set { mystring = value; }<br />
}<br />
}
I wonder if it is possible to set at runtime the DefaultValue for every properties. My wish is to be able to serialize theses values. So at next startup, the new defaultvalues will be used.
So what are the issues ?
- It's straightforward to enumerate the current DefaultValueAttribute of every properties.
- I think I have to use the ICustomTypeDescriptor to get a dynamic defaultValue attribute.
- I really don't know where to put the serialization and deserialization code for putting and getting back the default values. Constructor ? Desctructor ?
- Another point, by setting the DefaultValueAttribute of one propertie, will it be set for every instance of the class ?
Thanks for helping me.
---
Alexandre Jenny
|
|
|
|
|
Implement the ICustomTypeDescriptor in your class. In the implementation for GetProperties you can attach all the attributes to your <cdoe>PropertyDescriptors that you want. I use this for an object with "properties" that are allocated from a database, and I add a DefaultValueAttribute to those PropertyDescriptor s from the database as well.
If you simply want to serialize these, then you use the TypeDescriptor.GetProperties method to get the PropertyDescriptorCollection and enumerate those properties, getting the value from the DefaultValueAttribute which may be found in PropertyDescriptor.Attributes (inheritted from MemberDescriptor ).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have a user control that i created which contains a bunch of search varibles in the form of text boxes and drop-down lists. I include this control in the search page and a couple of others. I am trying to update the value of the textbox and drop down lists within this user control and can't. I have been able to read the values of the Controls using:
<br />
Control myKeywords = FindControl("ctl_search:tb_keywords");<br />
TextBox tb_keywords = (TextBox)myKeywords;<br />
tb_keywords.Text.ToString();<br />
But I need to update the value of those controls.
Any help you can provide would be greatly appreciated!
|
|
|
|
|
Why are you using Text.ToString ? Text already returns a string. This is a waste of CPU cycles.
If you're getting back a value (i.e., not null ) from FindControl , then just set cast to a TextBox as you're doing and set Text to some string, like tb_keywords.Text = "Some string"; .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I have to develop an Ssh client/server in c# and, enjoyed, i found that there's no c# library for .NET .
I've heard that it's possible to import classes from other language in c#, but i haven't found solution for my problem yet...
Help....
|
|
|
|
|
polkiujhy wrote:
Ssh client/server in c# and, enjoyed, i found that there's no c# library for .NET
A library to do what? The entire Secure Shell server and client? What would you be developing then?
RageInTheMachine9532
|
|
|
|
|
There's a mistake in my previous message. I wanted to say : "Ssh client/server in c# and, enjoyed, I found that there's no Ssh library for .NET"
I have to send and receive RPC messages through an ssh connection. So I have to develop first an Ssh client and server in c#, but i don't know how.
|
|
|
|
|
I haven't been able to find any classes that do Secure Shell in .NET or anything else for that matter. I have found various projects on SourceForge and other OpenSource websites. You can try this[^] Java example for code ideas.
RageInTheMachine9532
|
|
|
|
|
Why not just establish an ssh tunnel and send RPC commands to the local port, which is presumably forwarded to the remote RPC port. If the client has the ssh client install, you could simply invoke the command with the necessary parameters using the Process class.
There is one SSH client for .NET that I was able to find with a simple search on google for "SSH .NET": http://www.nsoftware.com/products/ipworksssh.aspx[^]. It's from IP*Works which, IMO, makes pretty good libraries.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am working an n-Tier application, and I have a component which is a representation of database tables (just collections of structs), I use this component as a container of data that can be sent between the tiers.
When I try to use an adding function on the server, I put the data from the client into one struct and send it as parameter to the server function but I am getting the following message
"Because of the security restrictions, the type Entities.Suppliers cannot be accessed"
as long as I try to get a list of the suppliers (returns a datatable) I have no problem.
|
|
|
|
|
Hello,
I'm fairly new to C# and I've got a syntax question. I've seen some C# syntax on the CP located above some function declorations, syntax like [sometext("more text")]. What does that mean? Where can I find documentation describing this?
An example of this syntax would be [DllImport("wininet.dll")], which I understand tells the compiler that you're importing the wininet.dll and are going to use a function in that dll.
Thanks!
|
|
|
|
|
These are called attributes. Attributes are used to further define or enhance certain metadata.
Attribute classes in .Net always end with "Attribute", although that part of the class name doesn't have to be provided when applying the attribute in code. For instance, if you wanted to look up information on DllImport in the MSDN library, you would actually look for the DllImportAttribute class.
For more information and a better starting point on attributes, try starting with this page in the MSDN library:
Introduction to Attributes[^]
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
Either in the Visual Studio Help or on MSDN here[^].
You can also search for keywords on MSDN.
RageInTheMachine9532
|
|
|
|
|
Any ideas on how to go about serializing a winform using C#.
|
|
|
|
|
Easy enough. Forms aren't serializable...
RageInTheMachine9532
|
|
|
|
|
As said, the Form class isn't serializable. But it should be enough to serialize step by step the most important properties like Size and Font.
|
|
|
|
|
...or extend Form and attribute the class with [Serializable] . By default, all private and protected fields are serialized if they themselves are serializable. If you want more control on how your class is serialized, implement the ISerializable interface. More information about the SerializableAttribute class and ISerializable interface can be found in the .NET Framework SDK documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi
i have a problem accessin the arraylist i made in a form by another form as i had to make static array and when i put data in it in for loop it just saves the last data the loop put what can i do?
thanx
|
|
|
|