|
|
thx a lot, it seems nice
troz
|
|
|
|
|
Hi all,
Is there a way of changing (or setting ) attributes (specifically ReadOnly) at runtime? I have looked at the CustomAttributeBuilder class but it seems to be difficult to understand and apply . I could be wrong.
Anyone?
Thanx all
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Nope, at least none that I know of.
Attributes are part of a types meta-data which is created at compile time so they aren't things that can be added and removed at runtime.
I think that CustomAttributeBuilder is used to create new Attributes for use in your Reflection.Emit generated code.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
O dear, but thanx anyways James
Maybe theres another way to do what i need. OK, what I need is a property that have a Get and a Set, but the Set should only be active at at certain application states.
Is this possible without having to dig thru all them Builder classes again?
UPDATE: the following does the job, but its still "editable" in a property grid. Can I make it "disabled" in some way so the user cant edit it?
public int Slots
{
get{return slots;}
set{if (state == State.Stopped)slots = value;} }
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
leppie wrote:
UPDATE: the following does the job, but its still "editable" in a property grid. Can I make it "disabled" in some way so the user cant edit it?
What exactly are you trying to do?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
Im trying to mess with your mind, no just kidding;P
I'm using a propertygrid to monitor a class Properties, but some properties should be able to be settable when the class is in a certain state. This is OK code wise , but like I said the Property is still "settable" according to the user (the brainless user that is), but as soon as he tries to enter a new value it will just revert to the current value, but I dont want to even allow this. I want a nice greyed out GridItem.
It doesnt really bother me, but I have allways taken the approach of Programming for the Dummies , iow what they cant click or change, they cant break, dont even generate interest or you will create an instant 10 finger virus.
Anyways, I will look at some of the code from the PropertyGridInternal namespace, it seems my answer mite lie somewhere deep in there.
Thanx
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Hi leppie,
have you found any workaround for this issue? My custom control has a property, which should be en/disabled depending on another property. I hope you've found a solution already
Regards
Thomas
Disclaimer: Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.
|
|
|
|
|
I think a type convertor could solve this. But you will have to keep track of some static members.
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
This is the code of an XML Web Service that Query an SQL Server.
It takes two strings and returns a DataSet.
It's a simple excercise, It query the database, populate a DataSet, modify a Field and Update the changes.
[WebMethod]
public DataSet GetUserData(string szUsername, string szNewLocalName)
{
string szSqlCommand = "SELECT * FROM Locals WHERE Username = '" + szUsername + "'";
SqlConnection myConnection = new SqlConnection(" User ID=sa;Password=password;Initial Catalog=laphijia;Data Source=(local)");
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(szSqlCommand, myConnection);
DataSet myDataSet = new DataSet();
mySqlDataAdapter.UpdateCommand = new SqlCommand("UPDATE Locals SET LocalName = @LocalName" +
"WHERE Username = @Username", myConnection);
mySqlDataAdapter.UpdateCommand.Parameters.Add("@LocalName", SqlDbType.NVarChar, 25, "LocalName");
SqlParameter workParam = mySqlDataAdapter.UpdateCommand.Parameters.Add("@Username", SqlDbType.NVarChar, 25);
workParam.SourceColumn = "Username";
workParam.SourceVersion = DataRowVersion.Original;
mySqlDataAdapter.Fill(myDataSet, "Locals");
myDataSet.Tables["Locals"].Rows[0]["LocalName"]= szNewLocalName;
mySqlDataAdapter.Update(myDataSet, "Locals");
return myDataSet;
}
I made this with help from the MSDN NET Framework Developer's Guide article Updating the Database with a DataAdapter and the DataSet.
When I try to access the Web Service and Invokes it, I get a 505 Internal Server Error.
I tried to remove the line:
mySqlDataAdapter.Update(myDataSet, "Locals");
and it works (it returns the DataSet as XML data, but obviously don't update the DataBase.
What's wrong with my code?
I also tried with the SQL Command Builder, but it's just the same.
Thank You.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
Try wrapping the Update code with a try/catch and see if something is happening there.
Maybe Alex sees something wrong with the call
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I tried changing the UpdateCommand with a custom string like "UPDATE locals SET LocalName = 'New Name' WHERE Username = 'john'"
This Worked, I mean, the Method returned the DataSet, and didn't give a 500 Internal Server Error, anyway the Method was completely USELESS now.
But I figured out that the problem is in the UpdateCommand Sql statement.
What's wrong there?
Username is not the Primary Key, it's only used for Authentication purposes on the final version.
How Can I have a correct Sql Statement, connected with the values that I could modify in the DataSet?
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
The only thing I can see that might be wrong with the SQL Query is that there is no space between the @LocalName parameter and the word WHERE.
If you wrap the dataadapter.update method call with a try/catch you could output any error that is generated, which should give you an idea of what to look for.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
James T. Johnson wrote:
The only thing I can see that might be wrong with the SQL Query is that there is no space between the @LocalName parameter and the word WHERE.
Could you believe it was just this?
Da*n!
Thank You,
this is the great thing about The Codeproject, that new eyes see subtle errors!
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
Hi,
How do I create a textbox that doesn't get the focus even when it is clicked upon (other than setting enabled = false)?
Thanks
|
|
|
|
|
Hi,
There are several ways
1. Try using a label instead , seeing that the user wont be able to enter text, or
2. On the MouseDown Event , make it select the control that requires focus, IOW as soon as it gets clicked on, it must deselect itself and select the required control.
Hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
To clarify, I am trying to create a textbox which, when the user types in numeric , will display those numbers but they shouldn't be able to directly click and type inside.
So a label won't solve the purpose.
|
|
|
|
|
|
jparsons wrote:
t.CanFocus = false;
That property is read-only . I wish it wasn't. Has cause major headache in the past
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Control.CanFocus is readonly. So I think this will not work.
|
|
|
|
|
I am creating a custom control that inherits the ComboBox class. I would like to use the ISite.DesignMode indicator to determine if the control is being viewed in design mode but the property always comes up false. MSDN documentation says the design mode indicator is stored in the ISite; therefore, if the Component does not have an ISite associated with it, this property is always false. Other things I have read said to assign the atribute to the class to designate which class to apply the ISite implementation but I have not seen any examples that put all the pieces together. Can anyone share with me this method or any other method that would allow me to determine when this custom control based on a combobox is in design mode?
Thanks,
Kyle
|
|
|
|
|
Does anybody know where i can get a trial version of C#?
|
|
|
|
|
The .NET Framework SDK is a free download +- 121MB from microsoft. You can use SharpDevelop as an IDE which is also free available
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Or you can order the trial version from this site:
http://msdn.microsoft.com/vstudio/productinfo/trial.asp
Have fun.
|
|
|
|
|
how can i clear screen in console applications?
|
|
|
|