|
Not sure what you mean by activation. I think you may be referring to either enabled or visible. Lets say it's the enabled property of the GroupBox. First you need to catch the SelectedIndexChanged event of the ComboBox, evalutate the selection and determine if the GroupBox should be enabled
private void MyComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
MyGoupbox.Enabled == (MyComboBox.SelectedValue == criteria);
}
Excuse the pseudocode but i think you get the idea
"You get that on the big jobs."
|
|
|
|
|
Hello.
I have a problem. I have two independient forms inside the same project and I want to call a function that is in the form 1 from form 2.
I am using c# for an window application
I have declared in the form 1 the following function:
public void Hola()
{
MessageBox.Show("Hello");
}
But I don´t know how to call from form2
Thank you very much!!
modified on Wednesday, May 18, 2011 11:22 AM
|
|
|
|
|
For a simple excercise, you could create a form level variable in form2 that holds a reference to form1. Then in form2 you can just call the function like this
public Form1()
{
InitializeComponent();
}
public void Hello(string name)
{
MessageBox.Show(string.Format("Hello, {0}", name)
}
public partial class Form2 : Form
{
Form1 form1;
public Form2()
{
InitializeComponent();
form1 = new Form1();
}
private void Form2_Load(object sender, EventArgs e)
{
form1.Hello("Wayne");
}
}
As a simple excercise, this is fine, but in a production app you would want to look into creating a Mediator class to communicate between classes, so that the entities have no need of any knowledge of each other.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
I am hoping this is not for your homework, but, I will answer nonetheless.
Two simple ways to accomplish this would be:
1. Declare your method in Form1 as static and invoke it from Form2 like so:
In Form1...
public static void Hola()
{
MessageBox.Show("Hello");
}
In Form2...
public void InvokeMessage()
{
Form1.Hola();
}
2. Using your declaration like so:
In Form2...
public void InvokeMessage()
{
using(Form1 otherForm = new Form1())
{
otherForm.Hola();
}
}
|
|
|
|
|
I'm assuming that Form1 creates the instance of Form2?
If so you should use an event in Form2 to signal and Form1 should subscribe to the event and call the method.
Basic theory is in this tip[^] which is about passing values but the same theory applies.
|
|
|
|
|
If you need to call a method in another form then the forms are not independent. Form1 is actually dependent on Form2. Sure you can make the method static but you should really consider refactoring this fuctionality into a separate class.
"You get that on the big jobs."
|
|
|
|
|
I have a problem, that is to mask data in certain format that is displayed in the browser
To solve the problem I came up with the following solution
1)Find all the browser window handles (class Internet Explorer_server)
2)Get the IHTMLDOCUMENT2 using the window handle
3)Use IHTMLDOCUMENT2::body::innerHTML to find the data I am looking for and modify it.
The code I have written below throws a COMException. [Could not set the innerHTML property. Invalid target element for this operation.]
IHTMLElementCollection dome = document.all;
foreach (IHTMLElement dom in dome)
{
StringBuilder bf = new StringBuilder(dom.innerHTML);
if (bf.ToString().Contains(pattern.ToString()))
{
bf.Replace(pattern.ToString(), "***-**-****");
dom.innerHTML = bf.ToString();
}
}
Why does this exception occur. How do I fix it so that the webpage contents will be altered.
I wrote another version of the code, it works, but not completely.
I found out that is because the webpage contains multiple frames and so it does not work. I does not work if the SSN number is inside a frame(or something like a frame which holds an embeded object).
StringBuilder bf = new StringBuilder(document.body.innerHTML);
if (bf.ToString().Contains(pattern.ToString()))
{
bf.Replace(pattern.ToString(), "***-**-****");
document.body.innerHTML = bf.ToString();
}
The first piece of code throws exceptions, the second one does not work if there are multiple frames.
What am I doing wrong in both the code above.
How do I go about achieving my solution. Is my approach correct, or is there a better way to do it.
Thanks and regards,
David
|
|
|
|
|
hi,
I want to build Multi user network Application
so what can i do .. for that..
|
|
|
|
|
You cannot really expect anyone to teach you how to build a complex application in a forum discussion. You need to do a lot more research yourself before you come here with more specific questions.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Do you mean that you want to build an application that conforms to a layered architecture (commonly known as an n-tier architecture)? If so, there are plenty of resources available on the web (or in books) to get you started. I would suggest that you should take a look at Rocky Lhotka's CSLA framework to get some idea as to what's involved in n-tier applications.
|
|
|
|
|
Nah. It's just another way of saying: i go to develop IM app plz send codez its urgent
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I want to fix the 5000 or so compile errors on our University's website because it hasn't been properly written since day 1.
You scratch my back?
|
|
|
|
|
Tequila, and lots of it, and the feeling will pass.
|
|
|
|
|
hemant saliya wrote: so what can i do .. for that..
Steps
1. Learn the basics of C#
2. Learn the basics of requirements gathering
3. Learn the basics of design
4. Learn the basics of "web" servers including various protocol types.
5. Learn how to program 4 in C#.
6. Use 2 to create your requirements
7. Use 3 and 6 to design your system.
8. Use 1, 4 and 7 to create your system.
9. Unit test your system.
|
|
|
|
|
I m using DataGridView.
It has a checkbox column, i want to check - uncheck this CheckBox control..
In asp.net FindControls() is used to get control, is there any methon like FindControls() for Windows ?
|
|
|
|
|
To set the value of a CheckBoxCell you need to cast it specifically like this:
(dataRow.Cells["your cell index"] as DataGridViewCheckBoxCell).Value = true;
This presumes dataRow is your current datagridview row.
Hope this helps
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Hi, Currently I have a server-client application which works fine. I only want the server to serve for a predefined number of clients. Say, up to 20 clients. If I adjust the below behavior it should be okay.
But since each client subscribe to server with a client number, e.g. client22 or client29 which are greater than number 20 will connect to server when the total number of concurrent sessions or instances are lover than 20. And so, if these two clients connect and allocate two connections before, Any two clients with numbers upto 20 will not be able to connect afterwards. Any solution for this? Thanks
in short: I want only 20 clients, client1,client2.....client20 can connect but client21, client22 and so on can't connect
ServiceThrottlingBehavior behaviour = new ServiceThrottlingBehavior();<br />
behaviour.MaxConcurrentSessions = 20;<br />
behaviour.MaxConcurrentInstances = 20;
|
|
|
|
|
What do "client number"s and ServiceThrottling settings have to do with each other?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Isn't the servicethrottling onyl way of limiting numbers of clients that can connect to server by controlling service instances and concurrency? So I want to limit max connections to a specific number of clients
|
|
|
|
|
Have you tried using sessions and limiting the number of sessions?
Besides the configuration you've shown, make sure sessions are required and concurrency/instance context modes are set on the service contract:
[ServiceContract(SessionMode = SessionMode.Required)]
public interface IService1
{
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession)]
public class Service1 : IService1
{
}
Sessions, Instancing, and Concurrency[^]
Discover Mighty Instance Management Techniques For Developing WCF Apps[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
I want to do the integrity check zip files, I would use 7zip library with the command 't' using this code:
try
{
Process rr = Process.Start(@"..\Release\7Z\7z.exe ", @" t ..\Release\.zip > .\1.test");
rr.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Order fontionne well on the lin command (CMD), except with the code below, it doesn't generate the file 1.test.
Thank you verry mutch.
|
|
|
|
|
abbd wrote: it doesn't generate the file 1.test.
If 7z had encountered an error, it would have written that to the file ".\1.test". There's also a space at the end of your path to the 7z-executable, that shouldn't be there. Does it print anything on the console if you run it?
Bastard Programmer from Hell
|
|
|
|
|
Hi,
I need to enumerate directories/shares (and their permissions), so far, I found two appraches:
OPTION 1: WMI[^]
- advantage: You can query remote computers if you have the permission to...[^]
- limitation is that: (a) Don't give local path, (b) I need "Permission", noth NTFS+Share, which WMI object don't provide.
This said, I did came across Win32_SecuritySettingOfObject[^], but don't know how to use it. And still trying Win32_SecuritySetting (But samples are so hard to decipher, for example, ControlFlags = 32772. This means absolutely nothing to me) [^] - how to get list of users/groups assigned to access to share folder?[^]
After more digging around, seems like answer (last challenge) is to call Win32_Share.GetAccessMask from C#[^] --- HELP! Sample from here don't work...[^]
OPTION 2: DllImport win32 API - WNetGetUniversalName and NetShareEnum [^]
- advantage: gives local path of identified shares and also able to scan both local/remote shares
- limitation: Option 2 actually gives local path, but nothing on directory/share "Permission".
note SHARE_INFO_2 has an "Permission (int)" field, but after examining further doesn't appear this is what I'm looking for. Also examined new System.IO.DirectoryInfo(share.Path) --- nothing useful from there.
Any suggestion guys? I need permissions - both NTFS+Share access permissions[^]... (Basically same as right click folder, select "Properties", look under "Security" tab and also "Sharing\Permissions")
Thanks!
OPTION 1 - sample code:
<br />
<br />
public static IList<string> EnumerateLocalShares(ShareCheckingMode Mode)<br />
{<br />
IList<string> Shares = new List<string>();<br />
SelectQuery query = null;<br />
ManagementObjectSearcher searcher = null;<br />
<br />
switch (Mode)<br />
{<br />
case ShareCheckingMode.Win32_LogicalShareAccess:<br />
query = new SelectQuery("SELECT * FROM Win32_LogicalShareAccess");<br />
break;<br />
case ShareCheckingMode.Win32_LogicalShareAuditing:<br />
query = new SelectQuery("SELECT * FROM Win32_LogicalShareAuditing");<br />
break;<br />
case ShareCheckingMode.Win32_LogicalShareSecuritySetting:<br />
query = new SelectQuery("SELECT * FROM Win32_LogicalShareSecuritySetting");<br />
break;<br />
}<br />
<br />
searcher = new ManagementObjectSearcher(query);<br />
foreach (ManagementBaseObject share in searcher.Get())<br />
{<br />
Console.WriteLine("Share: " + share.ToString());<br />
foreach (PropertyData prop in share.Properties)<br />
{<br />
Console.WriteLine("Property - " + prop.Name + ": " + prop.Value);<br />
}<br />
foreach (PropertyData prop in share.SystemProperties)<br />
{<br />
Console.WriteLine("SystemProperty - " + prop.Name + ": " + prop.Value);<br />
}<br />
foreach (QualifierData Qualifier in share.Qualifiers)<br />
{<br />
Console.WriteLine("Qualifier - " + Qualifier.Name + ": " + Qualifier.Value);<br />
}<br />
Console.WriteLine();<br />
Console.WriteLine();<br />
}<br />
<br />
return Shares;<br />
}<br />
For NTFS folder permission (Not "Share" permission) [^]
<br />
public static FileSystemAccessRule GetDirectoryPermissions(string user, string domainName, string folderPath)<br />
{<br />
if (!Directory.Exists(folderPath))<br />
{<br />
return (null);<br />
}<br />
<br />
string identityReference = ((domainName + @"\" + user) as string).ToLower();<br />
DirectorySecurity dirSecurity = Directory.GetAccessControl(folderPath, AccessControlSections.All);<br />
foreach (FileSystemAccessRule fsRule in dirSecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)))<br />
{<br />
if (fsRule.IdentityReference.Value.ToLower() == identityReference)<br />
{<br />
return (fsRule);<br />
}<br />
}<br />
return (null);<br />
}<br />
dev
modified on Wednesday, May 18, 2011 6:36 AM
|
|
|
|
|
I think I found how to enumerate share permissions. However, I can't interpret AccessMask = 1179817, MSDN didn't help (none of listed constants matches 1179817)[^]
I stumbled across this[^]
<br />
# Constants<br />
$SHARE_READ = 1179817<br />
$SHARE_CHANGE = 1245462<br />
$SHARE_FULL = 2032127<br />
$SHARE_NONE = 1<br />
Compared against actually setting, "1179817" is indeed READ.
<br />
ManagementObject sharedFolder = WMIUtil.GetSharedFolderObject("TestShare$");<br />
ManagementBaseObject securityDescriptorObject = sharedFolder.InvokeMethod("GetSecurityDescriptor", null, null);<br />
ManagementBaseObject securityDescriptor = securityDescriptorObject.Properties["Descriptor"].Value as ManagementBaseObject;<br />
int existingAcessControlEntriesCount = 0;<br />
ManagementBaseObject[] accessControlList = securityDescriptor.Properties["DACL"].Value as ManagementBaseObject[];<br />
existingAcessControlEntriesCount = accessControlList.Length;<br />
Array.Resize(ref accessControlList, accessControlList.Length + 1);<br />
foreach (ManagementBaseObject o in accessControlList)<br />
{<br />
WMIUtil.DisplayProperties(o);<br />
}<br />
<br />
Now ...
<br />
public static void DisplayProperties(ManagementBaseObject o)<br />
{<br />
if (o == null)<br />
{<br />
return;<br />
}<br />
<br />
Console.WriteLine();<br />
Console.WriteLine("Object: " + o);<br />
<br />
foreach (PropertyData prop in o.Properties)<br />
{<br />
if (prop.Value is ManagementBaseObject)<br />
{<br />
ManagementBaseObject childObj = (ManagementBaseObject)prop.Value;<br />
DisplayProperties(childObj);<br />
}<br />
else<br />
{<br />
Console.WriteLine("Property - " + prop.Name + ": " + prop.Value);<br />
}<br />
}<br />
<br />
foreach (PropertyData prop in o.SystemProperties)<br />
{<br />
Console.WriteLine("SystemProperty - " + prop.Name + ": " + prop.Value);<br />
}<br />
<br />
foreach (QualifierData Qualifier in o.Qualifiers)<br />
{<br />
Console.WriteLine("Qualifier - " + Qualifier.Name + ": " + Qualifier.Value);<br />
}<br />
<br />
return;<br />
}<br />
dev
modified on Thursday, May 19, 2011 3:30 AM
|
|
|
|
|
Is there a chance for a Dispose() method to be called by GC if class is not inhereted from IDisposable?
class My
{
public void Dispose()
{
}
}
I provided that method to immediatly release some memory resources for the class.
I wonder if it is prohibited to name some functions after well known methods as Dispose?
I experience the following problem Windows service stable APPCRASH in clr.dll after 3.5 to 4.0 .NET platform change[^] which occur in windows service application only.
Чесноков
|
|
|
|