|
I have question about browsable in propertygrid. I am trying to change browsable 's bool value bec sometimes it dont need to show all properties. Like sometimes First dont need to be browsable. I am well-aware that I cant change the browsable's value bec it need to be constant variable while it is run-time. what is your suggestions tht I can change browsable 's bool value while it is run-time?
For example:
for()
{
[Browsable(???)]///can be true or false
public string First
{
get { return m_strFirst; }
set { m_strFirst = value; }
}
[Browsable(???)]///can be true or false
public string Second
{
get { return m_strSecond; }
set { m_strSecond = value; }
}
[Browsable(????)]///can be true or false
public string Third
{
get { return m_strThird; }
set { m_strThird = value; }
}
}
|
|
|
|
|
Havent tested it but something like this should work (at least it should give you the idea of the right way):
<br />
public static void SwitchBrowsable(Type type, string propertyName) <br />
{<br />
object[] o = type.GetProperty(propertyName).GetCustomAttributes(typeof(BrowsableAttribute), true);<br />
if (o != null && o.Length > 0) <br />
{<br />
BrowsableAttribute ba = o[0] as BrowsableAttribute;<br />
ba.Browsable = !ba.Browsable;<br />
}<br />
}<br />
|
|
|
|
|
Thanks for the reply this messages. I followed your advice. I can get SwitchBrowsable working that can determines propertyName(First,Second,Third) is true or false. But I still cant change the bool value in property. I tried to use
ba.Browsable = !ba.Browsable;
but when I compiled and got error. it said:"
.ComponentModel.BrowsableAttribute.Browsable' cannot be assigned to -- it is read only"
I tried to used different ways to get bool value changed but no luck.
Do you have other ideas that need to fix like this:
ba.Browsable = !ba.Browsable;
|
|
|
|
|
Gurus,
Does anyone knows if the TreeView Controls that comes with .Net in WinForm has a sorting method ? Or I have to implement a callback function to achieve this. But before I head on and do this, wants to know if anyone has a better solution for this.
Stanley
|
|
|
|
|
Hi,
When my win app executes it opens in a maximized form and takes up 45,000K in mem. However, as soon as i minimize it, it cuts the mem usage in half. Is there are reason for this and is there any way of doing this type of mem clean up in the code. I tried using the garbage collection but it doesn't seem to do it.
thanks for any help
|
|
|
|
|
Minimising an app causes the OS to farm a lot of the memory it uses out to disk. It happens with every app.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
That’s the OSs memory management and optimization in action
If you minimize an app, it does not need to be as responsive as an active app. So the OS optimizes the situation by moving most of the app data to virtual memory, so the physical memory usage is reduced and that real estate is available for active foreground apps. If you maximize it again, the reverse thing happens.
Salil Khedkar [^]
|
|
|
|
|
hi
i have a form
sometimes(i dont know when and for what)
something happens that i can not close the form ie
when i click on the closeButton on the right upper corner of form
nothing happens and the application doesnt exit.
what should i do???
|
|
|
|
|
Your comments are rather nebulous; it's hard to say what is going on without you posting some code.
|
|
|
|
|
Nick Parker wrote:
nebulous
Yikes... I had to look that one up. Congrats on the MVP, Nick. Well deserved.
--Jesse
|
|
|
|
|
Thanks
|
|
|
|
|
That could be the infamous "Form not closing"-bug that's caused by child controls being removed from the form while they have focus.
Are you removing controls from your form at run-time?
That could be the problem.
In that case try setting the focus to a control remaining on the form before removing the other one.
Regards,
mav
|
|
|
|
|
I'm currently working on a project using a third-party tool. All of the data I'm working with is handled via MemoryStream for the most part, and in most cases need never be written to disk. (Completed document is streamed to the browser, then the stream discarded.)
Unfortunately, the 3rd-party tool I'm using only operates on files (both input and output.) I'd like to avoid having temp files everywhere if at all possible.
Is there any way through .Net that I can create an old-fashioned RAM disk to do this processing on? It'd be even better if there were a way to have a FAT record point to a memory buffer that already exists instead of having to actually duplicate the data on the RAM disk, but even that's preferable to actual disk I/O.
Thanks for whatever pointers anyone can give me.
(BTW, for those who're interested, or if it makes a difference, the 3rd-party tool I'm working with is GhostScript.)
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Not the answer you're directly looking for, but GhostScript is open source, so one solution would be to hack into GS the ability to read your data directly from RAM
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
True, but I'm on a short timeline, which is the main reason I'm using 3rd-party tools in the first place.
We had found a few 3rd-party solutions for doing what we actually need from ghostscript, but they all have their own problems. In some cases, they can't even render the PDF properly. That's the only reason I'm even looking at anything as low-level as Ghostscript.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Hi
I want to write a little Tool in c# that is scanning
the Network and list all founded Computers.. I think
I should use WMI. But I don't know how to scan te Network.
Can anybody help?
Greetings from Germany
|
|
|
|
|
Use NetServerEnum() API to get the list. Here is the complete code:
<code>using System;
using System.Net;
using System.Runtime.InteropServices;
namespace EnumDomainMachines
{
class AppClass
{
[STAThread]
static void Main(string[] args)
{
NetMachinesEnum NetMachinesEnumurator = new NetMachinesEnum();
NetMachinesEnumurator.PrintList();
Console.ReadLine();
}
}
class NetMachinesEnum
{
// server types accepted by the NetServerEnum function
public enum SV_101_TYPES:uint
{
SV_TYPE_WORKSTATION= 0x00000001,
SV_TYPE_SERVER= 0x00000002,
SV_TYPE_SQLSERVER = 0x00000004,
SV_TYPE_DOMAIN_CTRL= 0x00000008,
SV_TYPE_DOMAIN_BAKCTRL= 0x00000010,
SV_TYPE_TIME_SOURCE= 0x00000020,
SV_TYPE_AFP= 0x00000040,
SV_TYPE_NOVELL= 0x00000080,
SV_TYPE_DOMAIN_MEMBER = 0x00000100,
SV_TYPE_PRINTQ_SERVER = 0x00000200,
SV_TYPE_DIALIN_SERVER = 0x00000400,
SV_TYPE_XENIX_SERVER = 0x00000800,
SV_TYPE_SERVER_UNIX= SV_TYPE_XENIX_SERVER,
SV_TYPE_NT= 0x00001000,
SV_TYPE_WFW= 0x00002000,
SV_TYPE_SERVER_MFPN= 0x00004000,
SV_TYPE_SERVER_NT = 0x00008000,
SV_TYPE_POTENTIAL_BROWSER = 0x00010000,
SV_TYPE_BACKUP_BROWSER= 0x00020000,
SV_TYPE_MASTER_BROWSER= 0x00040000,
SV_TYPE_DOMAIN_MASTER = 0x00080000,
SV_TYPE_SERVER_OSF= 0x00100000,
SV_TYPE_SERVER_VMS= 0x00200000,
SV_TYPE_WINDOWS= 0x00400000, SV_TYPE_DFS= 0x00800000, SV_TYPE_CLUSTER_NT= 0x01000000, SV_TYPE_TERMINALSERVER= 0x02000000, SV_TYPE_CLUSTER_VS_NT = 0x04000000, SV_TYPE_DCE= 0x10000000, SV_TYPE_ALTERNATE_XPORT= 0x20000000, SV_TYPE_LOCAL_LIST_ONLY= 0x40000000, SV_TYPE_DOMAIN_ENUM= 0x80000000,
SV_TYPE_ALL= 0xFFFFFFFF
};
// Server info function, returned by the NetServerEnum function
[StructLayout(LayoutKind.Sequential)]
public struct SERVER_INFO_101
{
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)]
public UInt32 sv101_platform_id;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string sv101_name;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)] public UInt32 sv101_version_major;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)] public UInt32 sv101_version_minor;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.U4)] public UInt32 sv101_type;
[MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr)] public string sv101_comment;
};
public enum PLATFORM_ID
{
PLATFORM_ID_DOS = 300,
PLATFORM_ID_OS2 = 400,
PLATFORM_ID_NT = 500,
PLATFORM_ID_OSF = 600,
PLATFORM_ID_VMS = 700
};
// constants
public const uint ERROR_SUCCESS = 0;
public const uint ERROR_MORE_DATA = 234;
// System functions
// Imported from the NET api (See MSDN for more details)
[DllImport("netapi32.dll",EntryPoint="NetServerEnum")]
public static extern int NetServerEnum( [MarshalAs(UnmanagedType.LPWStr)]string servername,
int level,
out IntPtr bufptr,
int prefmaxlen,
ref int entriesread,
ref int totalentries,
SV_101_TYPES servertype,
[MarshalAs(UnmanagedType.LPWStr)]string domain,
int resume_handle);
[DllImport("netapi32.dll",EntryPoint="NetApiBufferFree")]
public static extern int
NetApiBufferFree(IntPtr buffer);
[DllImport ("Netapi32", CharSet=CharSet.Unicode)]
public static extern int NetMessageBufferSend(
string servername,
string msgname,
string fromname,
string buf,
int buflen);
public string GetIPAddress(string sHostName)
{
try
{
IPHostEntry ipEntry = Dns.GetHostByName(sHostName);
IPAddress [] addr = ipEntry.AddressList;
string sIPAddress = addr[0].ToString();
return sIPAddress;
}
catch
{
return("Unknown");
}
}
public void PrintList()
{
int entriesread=0,totalentries=0;
do
{
// Buffer to store the available servers
// Filled by the NetServerEnum function
IntPtr buf = new IntPtr();
// Server structure
SERVER_INFO_101 server;
// call NetServerEnum function. The '101' defines the type of
// structure returned, in this case, SERVER_INFO_101 which contains
// the type of information we need. In the preferred max length parameter
// '-1' is passed to tell the function to allocate the necessary amount of
// memory for the data. The SV_TYPE_WORKSTATION tells the function to only
// return workstation type servers.
int ret = NetServerEnum(null,101,out buf,-1,
ref entriesread,ref totalentries,
SV_101_TYPES.SV_TYPE_ALL,null,0);
// if the function returned any data, fill the tree view
if( ret == ERROR_SUCCESS ||
ret == ERROR_MORE_DATA ||
entriesread > 0)
{
Int32 ptr = buf.ToInt32();
Console.WriteLine("--------------------------------------------------------------------------");
Console.WriteLine(string.Format("{0,15} {1,17} {2,15} {3} {4} {5}",
"PLATFORM_ID",
"IP_ADDR",
"SERVER_TYPE",
"V",
"NO",
"COMMENT"));
Console.WriteLine("--------------------------------------------------------------------------");
for(int i=0; i<entriesread; i++)
{
// cast the pointer to a SERVER_INFO_101 structure
server = (SERVER_INFO_101)Marshal.PtrToStructure(new IntPtr(ptr),typeof(SERVER_INFO_101));
ptr += Marshal.SizeOf(server);
// add the workstation name to the tree view
Console.WriteLine(string.Format("{0,15} {1,17} {2,15} v{3}.{4} ({5})",
server.sv101_name.ToLower(),
GetIPAddress(server.sv101_name),
(PLATFORM_ID)server.sv101_platform_id,
server.sv101_version_major,
server.sv101_version_minor,
server.sv101_comment));
}
Console.WriteLine("--------------------------------------------------------------------------");
}
else
{
// no servers found
Console.WriteLine("No servers found in network");
}
// free the buffer
NetApiBufferFree(buf);
} while(
entriesread < totalentries &&
entriesread != 0
);
}
}
}
</code>
|
|
|
|
|
Hi Salil
Thank you for your reply! I'm really glad to get something
that I'm looking for a long time. But I get some Syntax Errors
when I try to compile your code. I don't want to change something.
for(int i=0; i **** ; expected******
{ **** invalid expression term'{' *****
Do you got the same Problems??
Regards
|
|
|
|
|
Oops since the code had special characters it got garbled. I have mosified the post above, copy-paste the code again. Or see this correction:
<code>for(int i=0; i<entriesread; i++)</code>
Anyways, the code is perfectly working. But if you still get more errors, treat it as an indicative code and build your logic on top of it... The basic idea is to use the NetServerEnum()API I described in earlier post.
If you can't make it work, I am writing a utility for a friend, which scans the network and gives hardware info report, but that will be ready next week. Ping me around next Friday.
|
|
|
|
|
No way to set the Datagrid Columns width in C# for Pocket PC by code. Can you please help me? Thanks
Gianni
|
|
|
|
|
Hello, just look this class.
public class MyClass : ArrayList
{
public MyClass ()
{}
public override int Add(object value)
{
return base.Add (value);
}
}
right, how to hide this method or make it private?
I don't want to see this method at intelisense when I call MyClass methods and properties.
tkx
Wender Oliveira
.NET Programmer
|
|
|
|
|
I don't think there is any way to hide the method in the manner you describe, and since it is a virtual method of the base (ArrayList) class, there's not really a way to obscure it - the accessibility of public virtual members can't be altered by the inheriting class.
The framework doesn't allow partial implementation inheritance. You could, however, change the behavior of your overridden version of the Add method to keep it from doing anything.
Perhaps a better option might be to create a new class that employs an ArrayList as a private field. You would then be free to manipulate the contents of the ArrayList at your discretion. Of course you lose some polymorphic benefits by doing so. You could also create a new Collection-type class (Add is not a member of the ICollection interface).
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
As far as I'm aware, it isn't possible to hide a public method inherited from a class lower in the hierarchy.
I'm not sure if the ArrayList as a base class was just for example purposes, but have you looked at derriving from System.Collections.CollectionBase instead? If the CollectionBase still exposes the method that you'd like to hide, the other solution that comes to mind would be to use the ArrayList as a private member of your class and simply wrapper the properties/methods that you'd like to expose.
Hope that helps.
--Jesse
|
|
|
|
|
Maybe EditorBrowsableAttribute can help you. It can be use to hide a member of a class from IntelliSense.
int ageval;
[EditorBrowsable(EditorBrowsableState.Never)]
public int Age
{
get { return ageval; }
set
{
if (!ageval.Equals(value))
{
ageval = value;
}
}
}
Daniel.
|
|
|
|
|
..please forgive me if my question sounds a bit basic but I am a newbie. One of the projects I've been tasked with is building a web based application that will be able to create questionnaires\surveys. This application will have various controls such as stop, start, address section, radio buttons, tickboxes, conditional boxes\sections etc.... Ideally the end user will be able to choose an element such as name, surname and date of birth as questions in the questionnaire. The user will then choose to release a version of this survey to a webserver where respondants will be able to answer the questions for the data to be collected. The main thinking behind this is that there are non technical staff that need to be able to create surveys\questionnaires without the need for in depth knowlegde of vb script or html, but an application with drag and drop or a point and click functionality would be more efficient. Is there any source code or sample available that could guide me through this? What is the best way to approach this? I have seen one approach where the application in question uses the required controls\objects to create an xml file that is uploaded to the web server which somehow translates the xml file into a set of functional web pages that collect all this data to an sql database. How difficult would that be to do? The name of the application that does this similar thing is called easyqd here is the website http://www.easyqd.com/
whether you believe you can or you can't you will be right
|
|
|
|
|