|
|
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Have you thought of using reflection? Reflection won't work with local variables, but will work with properties.
|
|
|
|
|
Thanks. It works with Reflection.
Do your best to be the best
|
|
|
|
|
Rework it into an array or hashtable.
|
|
|
|
|
Use reflection. Because you are using members you will have to use FieldInfo not PropertyInfo.
Of course, like others have mentioned, I would use a hash instead of members.
File Not Found
|
|
|
|
|
Hello everybody.
In my C# project I have a dataGridView with 12 Columns and 16 Rows.
Propertie ColumnHeadersVisible is set true;
How to enter value(text) into Cell between Row headers and Column headers (Cell in Topleft corner) in my dataGridView?
Thanks in advance.
|
|
|
|
|
I only found how to do it via code, not in a visual way, but it does the trick:
dataGridView1.TopLeftHeaderCell.Value = "SomeTextHere";
Hope this helped!
|
|
|
|
|
|
My first solution! I am great. Do I get a prize now?
public object BufferOverFlow<br />
{<br />
__get { return BufferOverFlow; }<br />
__set { BufferOverFlow = value; }<br />
}
|
|
|
|
|
To enter value in the first cell of the first row:
dataGridview.Rows[0].Cells[0].Value = "ABC";
Regards
joonyo's solution is correct. Sorry! I didn't pay attention to the details.
-- modified at 7:57 Monday 19th March, 2007
________________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
hi,
I am having a datagrid with 4 columns and one of the column type is combobox.
I am adding items to that combobox column i am able to add it.
now i want to display the first item in the combobox by default.
Now i am selecting it ,manually
help me pls
With Regards
prasad
|
|
|
|
|
Hi
Set comboObject.SelectedIndex = 0;
0 -> if first item in the list to be displayed by default
1 -> second item ....
Harini
|
|
|
|
|
hi,harini
I am getting in normal combobox property like selectedindex.
But i am using a datagridview in that one my colummn is made as combobox
help me
|
|
|
|
|
Hi
Post your code where you have added values in combo list.
Are you adding values during run time or using code behind file?
if Design time, then you can give selected=true ...
Harini
|
|
|
|
|
hi,this is adding the all clumns but i want to add single row itself.
I am getting error if i add rows saying that value doesn't match for datagridcombox column that is second column.
OpenFileDialog ObjOpenFileDialog = new OpenFileDialog();
ObjOpenFileDialog.DefaultExt = "*.cs";
ObjOpenFileDialog.Filter = "CSharp Script Files |*.cs";
if (ObjOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && ObjOpenFileDialog.FileNames.Length > 0)
{
Column3.Items.Add(ObjOpenFileDialog.FileName);
//scriptDGView.Rows.Add(true, ObjOpenFileDialog.FileName, "", "");
}
ObjOpenFileDialog.Dispose();
help me pls
|
|
|
|
|
i want to know ip adresses of all the systems which are active on my LAN.......DNS. gives me ip address of local machine but i want to know the ip address of all the connected systems
|
|
|
|
|
This is something i've put together a while ago...
Hope it would be useful.
I can't remember well but I believe it works under XP and later editions.
Its part of a larger project so I just copied the important stuff...
Its not located in a single file as it may appear here.
Enjoy... :P
#region Enums
/// <summary>
/// Net API return values.
/// </summary>
public enum NetApiStatus
{
/// <summary>
/// Operation completed with successfully.
/// </summary>
Success = 0,
/// <summary>
/// No servers found.
/// </summary>
NoBrowserServersFound = 6118,
/// <summary>
/// More data exists but not fetched due to a low prefered maximum length.
/// </summary>
MoreDataExists = 234,
/// <summary>
/// Network is busy.
/// </summary>
Busy = 54,
/// <summary>
/// Network name was deleted.
/// </summary>
NameDeleted = 64,
/// <summary>
/// Network access was denied.
/// </summary>
AccessDenied = 65
}
/// <summary>
/// Defines the level of information associated with a computer.
/// </summary>
public enum InformationLevel
{
/// <summary>
/// Information about the specified server, including the name and platform.
/// </summary>
ServerInfo100 = 100,
/// <summary>
/// Information about the specified server, including name, platform, type of server, and associated software.
/// </summary>
ServerInfo101 = 101
}
/// <summary>
/// Server types used to filter servers lists.
/// </summary>
[Flags()]
public enum ServerType : uint
{
/// <summary>
/// Apple File Protocol servers.
/// </summary>
AFP = 0x40,
/// <summary>
/// All servers.
/// </summary>
All = 0xFFFFFFFF,
/// <summary>
/// Return list for alternate transport.
/// </summary>
AlternateXPort = 0x20000000,
/// <summary>
/// Server running a browser service as backup.
/// </summary>
BackupBrowser = 0x20000,
/// <summary>
/// Server clusters available in the domain.
/// </summary>
ClusterNT = 0x1000000,
/// <summary>
/// IBM DSS (Directory and Security Services) or equivalent.
/// </summary>
DCE = 0x10000000,
/// <summary>
/// Root of a DFS tree.
/// </summary>
DFS = 0x800000,
/// <summary>
/// Server running dial-in service.
/// </summary>
Dailin = 0x400,
/// <summary>
/// Backup domain controller.
/// </summary>
DomainBackupController = 0x10,
/// <summary>
/// Primary domain controller.
/// </summary>
DomainController = 0x8,
/// <summary>
/// Primary domain.
/// </summary>
DomainEnum = 0x80000000,
/// <summary>
/// Server running the domain master browser.
/// </summary>
DomainMaster = 0x80000,
/// <summary>
/// LAN RcmManager 2.x domain member.
/// </summary>
DomainMember = 0x100,
/// <summary>
/// Servers maintained by the browser. See the following Remarks section.
/// </summary>
LocalListOnly = 0x40000000,
/// <summary>
/// Server running the master browser service.
/// </summary>
MasterBrowser = 0x40000,
/// <summary>
/// Novell servers.
/// </summary>
Novell = 0x80,
/// <summary>
/// Windows NT workstation or server.
/// </summary>
NT = 0x1000,
/// <summary>
/// ParmNum.
/// </summary>
ParmNum = 105,
/// <summary>
/// Server that can run the browser service.
/// </summary>
PotentialBrowser = 0x10000,
/// <summary>
/// Server sharing print queue.
/// </summary>
PrintQueue = 0x200,
/// <summary>
/// A LAN RcmManager server.
/// </summary>
Server = 0x2,
/// <summary>
/// Microsoft File and Print for NetWare.
/// </summary>
ServerMFPN = 0x4000,
/// <summary>
/// Windows Server 2003, Windows 2000 server, or Windows NT server that is not a domain controller.
/// </summary>
ServerNT = 0x8000,
/// <summary>
/// OSF Servers.
/// </summary>
ServerOSF = 0x100000,
/// <summary>
/// Unix servers.
/// </summary>
ServerUnix = Xenix,
/// <summary>
/// Any server running with Microsoft SQL Server.
/// </summary>
SQLServer = 0x4,
/// <summary>
/// Terminal Server.
/// </summary>
Terminal = 0x2000000,
/// <summary>
/// Server running the Timesource service.
/// </summary>
TimeSource = 0x20,
/// <summary>
/// Server running Windows for Workgroups.
/// </summary>
WFW = 0x2000,
/// <summary>
/// Windows 95 or later servers.
/// </summary>
Windows = 0x400000,
/// <summary>
/// Workstation servers.
/// </summary>
Workstation = 0x1,
/// <summary>
/// Xenix servers.
/// </summary>
Xenix = 0x800,
}
/// <summary>
/// Identifies the platform of a computer.
/// </summary>
public enum PlatformId
{
/// <summary>
/// Dos Platform.
/// </summary>
DOS = 300,
/// <summary>
/// NT Platform.
/// </summary>
NT = 500,
/// <summary>
/// OS2 Platform.
/// </summary>
OS2 = 400,
/// <summary>
/// OSF Platform.
/// </summary>
OSF = 600,
/// <summary>
/// VMS Platform.
/// </summary>
VMS = 700
}
#endregion
#region Structs
/// <summary>
/// Contains information about the specified server, including the name and platform.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct ServerInfo100
{
/// <summary>
/// Specifies the information level to use for platform-specific information.
/// </summary>
public PlatformId PlatformID;
/// <summary>
/// Pointer to a Unicode string specifying the name of a server.
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string Name;
}
/// <summary>
/// Contains information about the specified server, including name, platform, type of server, and associated software.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct ServerInfo101
{
/// <summary>
/// Specifies the information level to use for platform-specific information.
/// </summary>
public PlatformId PlatformID;
/// <summary>
/// Pointer to a Unicode string specifying the name of a server.
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string Name;
/// <summary>
/// Specifies, in the least significant 4 bits of the byte, the major release version number of the operating system. The most significant 4 bits of the byte specifies the server type. The mask MAJOR_VERSION_MASK should be used to ensure correct results.
/// </summary>
public int VersionMajor;
/// <summary>
/// Specifies the minor release version number of the operating system.
/// </summary>
public int VersionMinor;
/// <summary>
/// Specifies the type of software the computer is running.
/// </summary>
public ServerType Type;
/// <summary>
/// Pointer to a Unicode string specifying a comment describing the server. The comment can be null.
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)]
public string Comment;
}
/// <summary>
/// Provides methods to retreive information regarding the network.
/// </summary>
public static class NetworkInformation
{
private const int MaxPreferedLength = -1;
[DllImport("Netapi32.dll", SetLastError=true)]
private static extern NetApiStatus NetServerEnum([MarshalAs(UnmanagedType.LPWStr)] string serverName, InformationLevel level, out IntPtr pBuffer, int prefMaxLen, out int entriesRead, out int totalEntries, ServerType serverType, [MarshalAs(UnmanagedType.LPWStr)]string domain, out int resumeHandle);
[DllImport("Netapi32.dll")]
private static extern NetApiStatus NetApiBufferFree(IntPtr pBuffer);
/// <summary>
/// Gets a collection representing the computers currently on the network.
/// </summary>
/// <param name="servers">The type of servers to look for.</param>
/// <param name="level">The level of information to obtain.</param>
/// <returns>The computers currently on the network.</returns>
/// <exception cref="System.Exception">Thrown when the operation could not be completed.</exception>
public static ArrayList GetNetworkComputers(ServerType servers, InformationLevel level)
{
IntPtr pBuffer;
int entriesRead;
int totalEntries;
int resumeHandle;
NetApiStatus status = NetServerEnum(null, level, out pBuffer, MaxPreferedLength, out entriesRead, out totalEntries, servers, null, out resumeHandle);
if (status == NetApiStatus.Success || status == NetApiStatus.MoreDataExists)
{
try
{
ArrayList computers = new ArrayList(entriesRead);
int structSize = 0;
if (level == InformationLevel.ServerInfo100)
structSize = Marshal.SizeOf(typeof(ServerInfo100));
else if (level == InformationLevel.ServerInfo101)
structSize = Marshal.SizeOf(typeof(ServerInfo101));
int int32pBuffer = pBuffer.ToInt32();
for (int i = 0; i < entriesRead; ++i)
{
IntPtr pInfo = new IntPtr(int32pBuffer + i * structSize);
if (level == InformationLevel.ServerInfo100)
{
ServerInfo100 info = (ServerInfo100)Marshal.PtrToStructure(pInfo, typeof(ServerInfo100));
computers.Add(info);
}
else if (level == InformationLevel.ServerInfo101)
{
ServerInfo101 info = (ServerInfo101)Marshal.PtrToStructure(pInfo, typeof(ServerInfo101));
computers.Add(info);
break;
}
}
return computers;
}
catch
{
throw;
}
finally
{
if (pBuffer != IntPtr.Zero)
NetApiBufferFree(pBuffer);
}
}
else if (status == NetApiStatus.NoBrowserServersFound || status == NetApiStatus.NameDeleted || status == NetApiStatus.AccessDenied || status == NetApiStatus.Busy)
{
// Get a string representing the status enumeration
string statusMsg = status == NetApiStatus.NoBrowserServersFound ? "No servers found." : status == NetApiStatus.NameDeleted ? "Network name deleted." : status == NetApiStatus.AccessDenied ? "Network access denied." : "Network busy.";
throw new NetworkStatusException(status, "Could not find network computers: " + statusMsg);
}
else
{
Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
}
return null;
}
/// <summary>
/// Gets a collection representing the computers currently on the network.
/// </summary>
/// <param name="level">The level of information to obtain.</param>
/// <returns>The computers currently on the network.</returns>
/// <remarks>This overload retrieves all server types.</remarks>
/// <exception cref="System.Exception">Thrown when the operation could not be completed.</exception>
public static ArrayList GetNetworkComputers(InformationLevel level)
{
return GetNetworkComputers(ServerType.All, level);
}
}
/// <summary>
/// The exception that is thrown when a network operation could not be completed.
/// </summary>
[Serializable()]
public class NetworkStatusException : Exception
{
#region Member Variables
private NetApiStatus status;
#endregion
#region Construction / Destruction
/// <summary>
/// Instantiates a new NetworkStatusException object.
/// </summary>
/// <param name="status">The invalid status which triggered the exception.</param>
public NetworkStatusException(NetApiStatus status)
: base("The operation cannot be completed due to an invalid network status.")
{
this.status = status;
}
/// <summary>
/// Instantiates a new NetworkStatusException object.
/// </summary>
/// <param name="status">The invalid status which triggered the exception.</param>
/// <param name="message">The message explaining the reason for the exception.</param>
public NetworkStatusException(NetApiStatus status, string message)
: base(message)
{
this.status = status;
}
#endregion
#region Properties
/// <summary>
/// Gets the invalid status of the network at the time of the exception.
/// </summary>
public NetApiStatus Status
{
get
{
return status;
}
}
#endregion
}
Regards,
Shy.
|
|
|
|
|
Hi,
I'm trying to load an XML file and got the "System.Net.WebException was unhandled" Message="The operation has timed out". Is it due to the loading operation timing out? How do I overcome this problem? I saw the following at msdn but do not know how to implement the "solution". Can anyone kindly advise pls. Thanks.
solution at msdn:
Service1 obj = new Service1();
obj.TimeOut = -1; // infinite time out.
-- modified at 22:31 Sunday 25th March, 2007
|
|
|
|
|
First question to provide an answer to is where are you loading the Xml file from? Based on the fact that you're getting a WebException you must be loading it from the network somewhere. Have you established that this file does indeed exist and that you can download copies of it?
|
|
|
|
|
Hi,
indeed I'm loading it from the company network. The file exist for I am able to load it from IE w/o problem. However, the file is hosted in my company server so using IE to load it is accessing from LAN so no problem? I'm able to load the Xml from the program but sometimes it throws this timeout exception but loading from IE doesn't give any problem. So any ideas and suggestions please. Many thanks.
-- modified at 22:59 Tuesday 20th March, 2007
|
|
|
|
|
Based on the fact that the program can load the xml file occasionally I don't think that it's a problem with the code, it's more likely to be a problem with the network or permissions somewhere.
Sorry I can't be more specific.
|
|
|
|
|
I am a new C# sharp programmer and currently working on a project for a small company. The project should resuult in a software that could enable people on a network to communicate with one another as they please. Talk a about it as working like an intercom. Am using the power that .NET provides to accomplish this. I know of applications developed in .NET to run on windows platforms. Is it possible to develop .NET applications that could run on say a LINUX sever or any other server? If so then how can it be done?
I will be very grateful if my problem is addressed.
David Ssali
C.T.O Magezi Solutions
|
|
|
|
|
Take a look at the Mono Project[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
dvdssali wrote: I know of applications developed in .NET to run on windows platforms. Is it possible to develop .NET applications that could run on say a LINUX sever or any other server? If so then how can it be done?
That's because there is Windows implementation of .NET (Microsoft .NET Framework). Since .NET is in fact standardized, there can be implementations on other platforms as well. For non-Windows world, there is one - called Mono[^]
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|