|
dcof wrote: Error 56 The type or namespace name 'ActiveDirectoryUser' could not be found (are you missing a using directive or an assembly reference?)
"Add a new assembly reference to System.DirectoryServices.dll. This provides access to the System.DirectoryServices namespace that contains managed types to help with Active Directory querying and manipulation."
dcof wrote: Error 55 'Desktop.CurUser': cannot declare instance members in a static class
Mark it with the "static" keyword, if it's appropriate a
Bastard Programmer from Hell
|
|
|
|
|
Hi,
I have a textbox control with 2 buttons for different actions to perform.
Now, there is a check on this textbox, which I am initiating by using OnTextChanged method.
While this is initiated, I want the buttons to be greyed, otherwise this check is not complete till the user clicks on the screen again or clicks to the next textbox.
That way they cannot change some value and access the submit buttons without this method being completed.
Thanks.
|
|
|
|
|
Your description is extremely hard to understand.
Why don't you just disable the buttons if the text field is empty, and enable them in the textChanged event handler if the proper conditions are met.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I apologize for this.
But, I want an action to take place only if the text value has changed.
The problem is the onTextChanged method is not completed till the user clicks on the computer screen or tabs to the next textbox. If you are using a mouse, then you are not clicking anywhere on the screen and have the option to click on the button which should not happen.
|
|
|
|
|
vanikanc wrote: the onTextChanged method is not completed till the user clicks on the computer screen or tabs
That doesn't sound right. The TextChanged event fires on every change, right away, no special user action required. This code would prove that:
System.Windows.Forms.TextBox tb;
System.Windows.Forms.Label label;
public void Test() {
Form f=new Form();
tb=new TextBox();
tb.Bounds=new Rectangle(10,10,100,20);
f.Controls.Add(tb);
label=new System.Windows.Forms.Label();
label.Bounds=new Rectangle(10, 50, 100, 20);
f.Controls.Add(label);
tb.TextChanged+=new EventHandler(tb_TextChanged);
f.ShowDialog();
}
void tb_TextChanged(object sender, EventArgs e) {
label.Text=tb.Text;
}
|
|
|
|
|
The 'trouble' with the WinForms 'TextBox' 'TextChanged' Event is that it doesn't give you much information: its 'event argument' is just a dumb old 'EventArgs.
If you use the 'Leave event of the TextBox to judge the user is done, imho that's an 'ambiguous' choice that can lead to confusion, since all it means is the user shifted focus to some other control or object.
A TextBox with its 'MultiLine' property set to 'false, will ignore Enter/Return key-presses, and the focus will stay in the TextControl. The properties 'AcceptsTab, and 'AcceptsReturn only apply to MultiLine = 'true TextBoxes.
A Tab entry is going to move the focus to the next control in the tab-order; again, imho, an unsatisfactory way to handle the need to know the user has finished doing whatever they want to do with a TextBox.
The KeyPress, KeyDown, and KeyUp events give you access easily to which key is pressed.
So, what to do ? Since it is something of a convention that hitting the 'Enter key means you are 'done' with something, why not use that:
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
{
}
} Another idea I would consider, if dealing with users who were not 'socialized' to 'enter key = done' ... would be to make a UserControl that would be a combination of a CheckBox and a TextBox.
good luck, Bill
"Is it a fact - or have I dreamt it - that, by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time? Rather, the round globe is a vast head, a brain, instinct with intelligence!" - Nathanial Hawthorne, House of the Seven Gables
|
|
|
|
|
The Observer Patterns provides more flexibility to handle events when compared to the Proxy Patterns?
Thanks for the help and attention...
|
|
|
|
|
Of course it does as the Proxy Pattern has absolutely sod all to do with events. Did you even read the answer below?
|
|
|
|
|
What's the difference between Proxy Patterns and Observer Patterns? and the observer provides more flexibility to handle events when compared to the Proxy?
Thanks for the help and attention...
|
|
|
|
|
A Proxy pattern is essentially a class representing an interface to something else.
Observer pattern is where an object notifies all its listeners whenever it changes.
So both are very different patterns used for different tasks, and cannot really be compared.
Search more on the internet, you will get samples and lots of code for these patterns.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Can you tell me what is wrong with this code?
In an exisitng C#.net 2008 desktop application, I want to setup a class .cs file so I can do security checks against the active directory. I want to add this code to a project file that contains lots of common routines all the other processing modules use. The code is the following:
using System;
using System.Reflection;
using System.Runtime.Remoting;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using System.Security.Principal;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace En.Common
{
class ActiveDirectory
{
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
//Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
//if ((!Thread.CurrentPrincipal.IsInRole("testit")))
}
}
I want to start with 3 lines of code listed so far. However, the statement,
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
However I am getting the following two errors on this statement:
Error 94 Invalid token '(' in class, struct, or interface member declaration
Error 95 Invalid token ')' in class, struct, or interface member declaration
|
|
|
|
|
You need to put your statements into a method or constructor. At the moment it is like you are declaring then as class level variables.
Next time please put your code into Code Blocks. It makes it much easier to read!
Live for today. Plan for tomorrow. Party tonight!
|
|
|
|
|
I've created a custom control with a non-rectangluar border.
I'm trying to set the region properly and struggling to get a *filled* region.
I can make it the outline of my control, but then you can't drag the control from the middle.
How do I *fill* a region?
|
|
|
|
|
The Region property should be set to a collection of closed subpaths. Use the GraphicsPath methods to add a closed shape (e.g. AddPolygon, AddEllipse etc) or call CloseFigure for each subpath.
E.g. a circular control:
private void AdjustRegion()
{
GraphicsPath path = new GraphicsPath();
path.AddEllipse(-(Size * 0.5f) - 2, -(Size * 0.5f) - 2, Size + 4, Size + 4);
this.Region = new Region(path);
}
|
|
|
|
|
mmm, I've got a series of lines added to a Path, and I do then call CloseFigure. But the region is *just* those lines, not the space enclosed by them.
Even if I add a rectangle to the path, its just the rectangles edge that gets added, not the area covered by it.
|
|
|
|
|
Are you assigning Region (property) to a new Region object like in my example?
I took that from a (more complex) working example in real code so it definitely works.
|
|
|
|
|
Yep, tis the same assignment...and I've got it working in another project as well...just have to keep looking.
|
|
|
|
|
Hi,
I have created a program e.g. test.exe by C#.net and I want to
associate file extension (eg .tst) with the test.exe in the window registry.
But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ?
or how can I convert my exe into dll so I can open the file type by the dll ?
Thanks
|
|
|
|
|
This isn't really a C# question.
File associations are stored in HKEY_CLASSES_ROOT/.ext. Most file types then have an almost empty key with the default value pointing to another key (typically 'extfile'). In that key, the default value is the friendly name for the type (appears in Windows Explorer and the File Types dialog). To associate the file type with a program, create a subkey Shell/open/command and for the default value in there, put the command to run (typically something like path/myapp.exe "%1" ).
|
|
|
|
|
Have done somethingg similiar. In the code below the file extension to be opened by the app is .stockcheckdata . This extension then needs to be associated with app, in my example the one being opened.
Registry.ClassesRoot.CreateSubKey(".stockcheckdata").SetValue("", "stockcheckdata", RegistryValueKind.String);
Registry.ClassesRoot.CreateSubKey(@"stockcheckdata\shell\open\command").SetValue("", Application.ExecutablePath + " \" %1 \"", RegistryValueKind.String);
Hope it helps?!
|
|
|
|
|
Try double-clicking the file and then tell Windows which app to use to open it.
|
|
|
|
|
Hi
I have a code in c# to read data in excelsheet.
string connstr = "provider = Microsoft.Jet.Oledb.4.0;Data Source='C:\\aaa.xls';Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(connstr);
string strSQL = "SELECT * FROM [Sheet1$]";
OleDbCommand cmd = new OleDbCommand(strSQL, conn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds);
dt = ds.Tables[0];
While reading i could not get few values in a particular column(say column B) and the values that are not being read are completely numeric(12345) while the others are alpha numeric(Ex: e0345) in the same column.
Example
Column B in excel has values as below
U098ij
i097hl
123453
gdtr56
When i see in the dataset, 3rd value is null. Dont know where i am going wrong. Please help me
Thanks in advance
Naina
Naina
|
|
|
|
|
There is a universal problem when accessing excel through ADO and that is that ADO only scans the first 8 lines and then chooses what data type to return based on the data type of the majority of the returned results. Thus if the majority of the returned results are strings, then it thinks that all the data should be returned as strings, and ignores other data types. The best way to get around this is to add the instruction IMEX=1 to the extended properties instruction in the connection string. Thus your connection string would now look like this:
string connstr = @"provider = Microsoft.Jet.Oledb.4.0;Data Source='aaa.xls';Extended Properties='Excel 8.0;IMEX=1'";
Of course, the problem with this is that all your data is returned as a string, and numeric values will need to be parsed.
Hope this helps
Live for today. Plan for tomorrow. Party tonight!
|
|
|
|
|
Wayne
Does this force large numbers into e##### format when converting to strings?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes, unfortunately it does do this if you have the cell format set to general or number. This can lead to a serious loss of data. If you format the cells to currency or accounting, then you get the actual value.
Live for today. Plan for tomorrow. Party tonight!
|
|
|
|