|
Yeah, I've got the validation portion down...
I need to get the character, which if entered proprly is an integer number, and convert it into an integer for processing.
|
|
|
|
|
Probably an easier way but this seems to work:
int val = Convert.ToInt32(e.KeyChar.ToString());
Good Luck!
“You can't teach people to be lazy - either they have it, or they don't.”
-Dagwood Bumbstead
|
|
|
|
|
Hi all!
I must set a psw to a directory, any ideas??
thanks
Bye
|
|
|
|
|
What is a "psw"?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
TJoe wrote: What is a "psw"?
I guess he means password
|
|
|
|
|
|
The short answer is that you cannot set a password on a folder.
The long answer is that it can be done, but is a total waste of time considering all the work you're going to have to do in C++ to pull it off writing NTFS file system extensions, a management tool to reset passwords, a database manager to maintain the password database, ...
Some of this stuff could be written in C#, but no the extensions to NTFS.
It's a complete waste of time betwen NTFS Security handles all of this and the users doesn't need to remember yet another password on top of the 5, 10, 15, 20+ passwords they already have to remember.
|
|
|
|
|
It's not really something you would do from C#, but I'm sure it's possible. Here is how to do it using Windows[^].
What exactly are you trying to accomplish? Are you trying to secure some files for your users, hide files from them, etc?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi, i must set a password to a directory beacause i'm try to secure some of my files...
Bye
|
|
|
|
|
How can I get the current open file of WORD, POWERPOINT and OUTLOOK.
say that im gonna print them or convert them from to tiff.
Using .NET and c#
it should be getcurrentfile(); or smthn any help?
thnx
|
|
|
|
|
I have combed the net for an answer to this and I can't seem to find one; am I missing something?!?
I currently have an application (C# Windows Form) that launches a C++ command-line tool with an myriad of command arguments. The C# application asynchronously captures the output and redirects it to a RichEditBox. I would like to restructure the tool and recompile it as a DLL but the code is riddled with printf statements. I've done small test cases with a simple printf inside of an otherwise empty function (in the DLL) but nothing shows up and I am unable to redirect it's output.
Has anyone solved this problem?
|
|
|
|
|
You can't redirect the printf output. It's going to go to the StandardOutput stream no matter what. You CAN redirect the StandardOoutput stream, but I believe that requires a console window to do. In other words, I don't believe you can't redirect it from a DLL since there is no StandardOutput stream without the console.
|
|
|
|
|
Hello all,
Odd title, not an easy one to summarise. Basically I am trying to find a way of access an object value from a string that contains that objects name.
So, lets assume I have the following basic class
class NoddyClass
{
public string foo;
public string bar;
}
Which is used by the following
class NoddyProcess
{
private NoddyClass nc;
public NoddyProcess()
{
this.nc = new NoddyClass()
this.nc.foo = "thingys";
this.nc.bar = "doodars";
}
public void GetValueFromString(string value)
{
}
}
class AnotherNoddyProcess
{
private void DoSomething()
{
NoddyProcess np = new NoddyProcess();
np.GetValueFromString("foo");
}
}
So putting all this together in the GetValueFromString method I need to access this.nc and using the passed string retrieve the value of this.nc.foo and return it to the caller.
I am assuming that this can be done with reflection, however I seem to have hit a wall on this and could do with a prod in the right direction.
P.S. I realise that in the examples given above none of this is actually necessary, however these are extemely simplfied versions of a much more complex framework.
|
|
|
|
|
Since you are accessing fields, check out this[^]. It has an example that should get you started.
For properties, check out this[^].
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
MrEyes wrote: however these are extemely simplfied versions of a much more complex framework.
This "much more complex framework" is what? Or is it what you are developing?
|
|
|
|
|
Basically I have a library that has an encrypted XML file sat underneath it, when the library object is created it reads in, decrypts and deserialises the XML to an class level object. This object is then used within the library to drive various things.
This library exposes a COM interface to allow none .NET applications to interact with it, and until today these external applications did not require the ability to directly extract data from the XML file.
Today however, this functionality is now a requirement.
The XML itself while structurally simple, contains alot of elements. In fact it looks something like this:
<Data>
<Element1></Element1>
<Element2></Element2>
....
....
<Element1000></Element1000>
</Data>
Due to the volume of elements it isnt really feasible to create an externally accessible property for every single one, i.e:
public string GetElement1Value
{
return this.myXmlObject.Element1
}
There was also the option of not using the current XML object in memory, re-reading, re-decrypting it, and then using XmlDocument and Xpath to get the value, however I belive the overhead here would be greater than using reflection.
So this is where the idea of using reflection comes in. In fact since posting I have found a solution, so this is what I am currently trying out:
public string GetConfigurationValue(string key)
{
Type itemType = typeof(MyXmlObject);
PropertyInfo property = itemType.GetProperty(key);
if (property == null)
{
throw new ArgumentException("Invalid XML element key", key);
}
return property.GetValue(this.myXmlObject, null).ToString();
}
Which as you can see is alot shorter than using 1000+ property accessor/methods.
Maybe I am barking up the wrong tree here, so feel free to point out something that I have considered as I have to admit using reflection doesnt sit very well with me.
|
|
|
|
|
MrEyes wrote: In fact it looks something like this:
WOW... I am sorry but using XML in that way crosses my threshold of acceptability. I am afraid I cannot assist you any further.
|
|
|
|
|
Ack.. you may want to reconsider this approach. Did you know that you can use XPath queries in XML documents using the XmlDocument class in .NET? This might serve your purpose alot better than attempting to manually extract fields in this manner.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
This appeared to work for me, and I think it's what you want, using reflection. Note the Main method and GetValueFromString method. (Sorry for the formatting)
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
namespace ConsoleApplication1
{
class Program
{
static void Main(string [] args)
{
NoddyProcess p = new NoddyProcess();
object o = p.GetValueFromString("foo");
Console.WriteLine(o.ToString());
o = p.GetValueFromString("bar");
Console.WriteLine(o.ToString());
Console.Read();
}
}
class NoddyClass
{
public string foo;
public string bar;
}
class NoddyProcess
{
private NoddyClass nc;
public NoddyProcess()
{
this.nc = new NoddyClass();
this.nc.foo = "thingys";
this.nc.bar = "doodars";
}
public object GetValueFromString(string value)
{
FieldInfo info = nc.GetType().GetField(value,BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public );
return info.GetValue(nc);
}
}
class AnotherNoddyProcess
{
private void DoSomething()
{
NoddyProcess np = new NoddyProcess();
np.GetValueFromString("foo");
}
}
}
|
|
|
|
|
I want to display image in DataList.Path of image is saved in a table of databse Sql Server 2000.Someone help me , please.
nothing
|
|
|
|
|
How to create a link in a Excel worksheet to refer a local worksheet in the same workbook using Microsoft.Office.Interop.Excel . The link should not be absolute it should be relative so that the sheet can work properly if viewed in another machine .This should work much similar like a table of contents in a Word Document
Karthekeyan
|
|
|
|
|
First you have know exactly what you want to do in Excel terms so, "should work much similar like", is not sufficient.
Next to do this from C# you would use the Excel Object Model which is available through the Primary Interop Assembly which you can down load from Microsoft. The Excel Object Model is documented on MSDN.
|
|
|
|
|
I'd recommend start recording a Macro in Excel, perform the task you want, then stop recording. Then edit the macro to see what VBA code was generated. This will give you an idea of what to do. In this case, Excel generate the following code:
Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"Sheet2!A1", TextToDisplay:="This is a test"
The object model should be idential in the .Net API. See this[^] for documentation on the Hyperlinks.Add method.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi Tom,
Thanks very much for the tip off i was able to link sheets using hyper link now and its even relative not absolute. Below is the code to generate a relative hyperlink using C# through Microsoft.Office.Interop.Excel
Excel.Application xla = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook workbook = xla.Workbooks.Add(Excel.XlSheetType.xlWorksheet);
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.ActiveSheet;
Excel.Worksheet worksheet1 = (Excel.Worksheet)workbook.ActiveSheet;
worksheet.Hyperlinks.Add(worksheet.Cells[1,1],"","Sheet2!A1","Test","TestMe");
xla.Visible = true;
Regards,
karthekeyan.
|
|
|
|
|
Hi Friends,
I have a requirement to add new rows to the DataGridView UI which is bound to a DataTable.
The new row added to the UI should get added to the underlying DataSource.
I have bound the DataGridView to a DataSource.
The DataSource consists of 10 columns out of which only 5 columns were bound to the DataGridView.
The other 5 columns which are not bound consists of composite primary key on 2 columns and 3 other columns will not accept null values.
I have tried with "DefaultValueNeede" event of the DataGridView to define the default values for the new row.
As only 5 columns are bound to the DataGridView, I could supply the default values only to those columns.
How would I supply the default values to the rest of the columns which are not bound to the DataGridView?
Which event of the DataGridView should be handled in this scenario?
An exception is thrown when I tried to commit the new row in the DataGridView UI (by adding a "new new row") to the DataGrid.
The exception is that "Required values are not supplied to the new DataRow" which are the composite primary key columns (2) and not null columns (3).
Thanks.
Subrahmanyam K
|
|
|
|