|
...f is a Form
Control t_ctrl;
for (int i = 0; i < f.Controls.Count; i++)
{
t_ctrl = f.Controls[i];
TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text);
t_tn.Tag = t_ctrl;
self.treeView1.Nodes.Add(t_tn);
addNode(t_ctrl, t_tn);
}
...
private static void addNode(Control ctrl, TreeNode tn)
{
Control t_ctrl;
for (int i = 0; i < ctrl.Controls.Count; i++)
{
t_ctrl = ctrl.Controls[i];
TreeNode t_tn = new TreeNode(string.IsNullOrEmpty(t_ctrl.Text) ? t_ctrl.Name : t_ctrl.Text);
t_tn.Tag = t_ctrl;
tn.Nodes.Add(t_tn);
if (t_ctrl.Controls.Count != 0)
{ addNode(t_ctrl, t_tn); }
}
}
but is not full,some controls not got into the treeview1.such as ToolStripMenuItem.
somebody can give me some tips or advises.Thanks!
|
|
|
|
|
You should use a foreach, and you should write a recursive method, because some controls, contain controls.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thanks for your reply
I had already use the recursive method-->"addNode(Control ctrl, TreeNode tn)"
|
|
|
|
|
Controls inside a tool strip aren't available from the Controls property, you need to use the Items property instead.
|
|
|
|
|
So if I want to make it, I need to consider all those special controls,
It's not a easy thing,right?
Did anybody have idea about how display all controls in winfroms at runtime like vs2005 doc outline tool in designtime?
|
|
|
|
|
hwswin wrote: It's not a easy thing,right?
As there's no common interface to access child controls, I'm afraid not.
|
|
|
|
|
Does any one know of a Development tool that can create Command Shells or loadable modules in windows for C# for a server.
|
|
|
|
|
Hi all
I'm creating a web browser in C# and i've pretty much got what I needed and I keep getting stuck on one thing. When I'm browsing the web in my new browser and stumble upon a link that opens a new page in a new browser, or in a new tab or whatever, it opens that new page in internet explorer! lol. How can I stop this? It's really getting on my nerves, but it's making me laugh at the same time... I want to do something like this (and yes, i know this code will never work :p):
if Link is trying to open new page in new tab or window
then open that new page in a new tab in the current window.
... I know how to create new tabs, add a new webbrowser control to the new tab etc, i just don't know how to get those particular links to open up in a new tab. Does anybody have any ideas as to how I might go about doing this? I have looked on msdn and couldn't find anything. I also tried google and found a few links but then led me to something completely unrelated.
thanks,
jase.
modified on Thursday, June 11, 2009 1:44 AM
|
|
|
|
|
I need to write a development environment (editor) for writing ladder logic programs for PLCs. This is prt of a larger project. I can find no information anywhere on the net that could possibly point me in the right direction.
If anyone cangive me some direction as to where to look I would greatly appeciate it.
I am developing in C# and that is why I have chosen this forum.
Thanks,
Jim
|
|
|
|
|
There is a syntax highlighting control on CP, but it's in c++. I used it ages ago on a Python IDE.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi,
here are two suggestions:
1.
come up with functional specs
2.
do some research[^]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Your link to research only points out the lack of available information on the subject. All these links are for already developed editors. I need to write a new one.
|
|
|
|
|
JimLaVine wrote: All these links are for already developed editors.
Did you even try looking at/for the source code for some of them?? It's amazing what you can find by examining the source of another editor.
|
|
|
|
|
JimLaVine wrote: I need to write a development environment (editor) for writing ladder logic programs for PLCs.
No you don't. You could download the Visual Studio Shell, and write your own language here, using the Language Integration capabilities in Visual Studio.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Problem occurs when I exit out of the application.
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Whatever has been written to my config file and saved to the file
goes back to what it used to before.
I have no idea why ? Do you guys have any idea?
System.Configuration.Configuration config = null;
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(strJob, strValue);
config.Save();
|
|
|
|
|
Your asking for information that applies to all users, by specifying ConfigurationUserLevel.None . Not a per user level, which is what your trying to save.
Try the other types.
Also settings should be user level and not application level. Or they'll never change anyway.
Using the wrong tool for the job is half the fun.
|
|
|
|
|
Tried
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming);
crashed at Config.Save.
|
|
|
|
|
Hey all
Does anybody experience flickering of the desktop icons, application window icons (any open application) whilst visual studio c# express is running? like for example i'll go to debug and then if i open a context menu or do anything in my program everything on my computer starts to flicker. Desktop icons, icons inside programs, and other controls such as comboboxes buttons etc? I don't have any viruses/trojans or anything like that so I'm puzzled. And it only just started happening. I've never had this problem before, I do remember though reading on here a while ago about someone who had the same problem but don't remember any solutions or anything...
jase.
|
|
|
|
|
i have a program that authenticated users with Active directory how do i query AD to find out when is the last time a user was authenicated i trided using last logon time but this is only updated when they log on to the computer not when the authenticate
|
|
|
|
|
lastlogon is notorious in fact it doesn't even replicate if you have more than one DC. Try lastlogontimestamp. However this only works with 2003 server and above, and they have to be in the correct 2003 Domain mode. No 2000 servers.
Otherwise it's lastlogon and checking all the servers. and even then it might not be accurate.
Using the wrong tool for the job is half the fun.
|
|
|
|
|
Login Using Active Directory Services (ADS)
In order to use SDS, first we have to set properties of LDAP server. Here database ADSI_PARAMETER table is used to set the LDAP properties.
CREATE TABLE [dbo].[ADSI_PARAMETER] (
[ParameterName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ParameterValue] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
Enter following data to table in ParameterName and ParameterValue fields
Parameter Name ParameterValue
ServerName WindowsDomainServer
BaseDN DC=DomainName,DC=COM
UserDN OU=Users
GroupName CN=Operater, OU=Groups
AccountFilter sAMAccountName
Where ServerName is your domain server machine name. BaseDN is your domain name, most of the time it is company name. UserDN is organizational unit where user should exist. GroupName is organizational unit, to which user should belong in order to access your software. AccountFilter is filter for account name; mostly it is sAMAccountName in windows.
Code for GetADSILogin function.
public void GetADSILogin()
{
try
{
string strServerName = "";
string strBaseDN = "" ;
string strUserDN = "";
string strGroupName = "";
string strAccountFilter = "";
//Port no for LDAP Default is 389
string strPortNo = "389";
Boolean blnGroupUser=false;
//Data source string
string source = "Data Source=ATHAKUR;Initial Catalog=Times;user=sa;password=sa" ;
//SQL statement that will be issued
string select = "SELECT * from ADSI_PARAMETER";
//SQL Connection
SqlConnection conn=new SqlConnection(source);
// Open the database connection
conn.Open () ;
// Create the SQL command...
SqlCommand cmd = new SqlCommand ( select , conn ) ;
//Execute Data reader
SqlDataReader myReader = cmd.ExecuteReader();
//Check if any rows return against user/pass
if(myReader.HasRows)
{
while(myReader.Read())
{
//Store the parameter's data in variables
string strParameterName = myReader.GetString(0).Trim();
string strParameterValue = myReader.GetString(1).Trim();
if(strParameterName.ToUpper().Equals("SERVERNAME"))
strServerName=strParameterValue;
if(strParameterName.ToUpper().Equals("BASEDN"))
strBaseDN=strParameterValue;
if(strParameterName.ToUpper().Equals("USERDN"))
strUserDN=strParameterValue;
if(strParameterName.ToUpper().Equals("GROUPNAME"))
strGroupName=strParameterValue;
if(strParameterName.ToUpper().Equals("ACCOUNTFILTER"))
strAccountFilter=strParameterValue;
}
}
//Search for user
DirectoryEntry deSystem = new DirectoryEntry("LDAP://" + strServerName + "/" + strUserDN + ","
+ strBaseDN);
deSystem.AuthenticationType=AuthenticationTypes.Secure;
deSystem.Username=txtUserName.Text;
deSystem.Password =txtPassword.Text;
//Search for account name
string strSearch=strAccountFilter + "=" + txtUserName.Text;
DirectorySearcher dsSystem = new DirectorySearcher(deSystem,strSearch);
//Search subtree of UserDN
dsSystem.SearchScope= SearchScope.Subtree;
//Find the user data
SearchResult srSystem = dsSystem.FindOne();
//Pick up the user group belong to
ResultPropertyValueCollection valcol = srSystem.Properties["memberOf"];
if(valcol.Count>0)
{
foreach( object o in valcol )
{
//check user exist in Group we are searching for
if(o.ToString().Equals(strGroupName+","+strBaseDN))
{
blnGroupUser=true;
break;
}
}
}
if(blnGroupUser==true)
MessageBox.Show("Login Sucessfull...");
else
MessageBox.Show("User Does Not Belong to Specified ADSI Group");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
i=i+1;
if(i==5)
{
MessageBox.Show("Login failed for 5 times. Quiting...");
this.Close();
}
}
If everything works fine then you will get the message "Login Successful". If user does not belong to group specified in LDAP properties then will the message "User Does Not Belong to Specified ADSI Group". If you enter wrong user/pass, you will get Logon failure message.
|
|
|
|
|
That's alot of work and a complete waste considering you didn't even the the OP's question...
|
|
|
|
|
Heres what I do now
Type a = b.GetType();
if (a.Name == "Blog")
{
Console.WriteLine("blog = {0}", ((Blog)b).text);
error = "ok";
return 0;
}
if (a.Name == "String")
{
Console.WriteLine("blog = {0}", (String)b);
error = "ok";
return 0;
}
Console.WriteLine("blog = TypeError");
error = "unKnownType";
return 1;
I want to set the type similar to this
((GetType())b).text
How can I do this ?
|
|
|
|
|
If b implements the interface IBlog, then you can cast b to an IBlog and provided Text is part of the interface declaration and is implemented in b's class, you can get the text. Something like:
interface IBlog
{
public string text { get; }
}
public class Blog : IBlog
{
public string text
{
get { return "name"; }
}
}
public int testThisExample()
{
object b = new Blog();
if(b is IBlog)
Console.WriteLine("blog = {0}", (b as IBlog).text);
return 0;
}
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
You could override the ToString() function in the Blog class.
class Program
{
static void Main( string[] args )
{
object obj = "Test from string";
Console.WriteLine("The result of to string is:" + obj.ToString());
obj = new Test();
Console.WriteLine("The result of to string is:" + obj.ToString());
Console.ReadKey();
}
}
public class Test
{
public override string ToString()
{
return "Test from class";
}
}
Using the wrong tool for the job is half the fun.
|
|
|
|