|
I'm converting a VB app that makes use of the FlexGrid control to C#. Does anyone provide such a control for C#?
|
|
|
|
|
System.Windows.Forms.DataGrid offers data-binding functionality in a grid, but doens't offer many of the features of the FlexGrid without implementing DataGridColumnStyle derivatives yourself (for which there is articles here on CodeProject et. al.). ComponentOne does have a FlexGrid for .NET available here: http://www.componentone.com/products.aspx?ProductCode=1&ProductID=17[^].
Note that in .NET 2.0 the DataView control will be much better than the current DataGrid and better even, IMO, than FlexGrid - besides being easier to extend.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If you are using ComponentOne's FlexGrid control, we have a version for C# (FlexGrid.NET). You can download a trial version from the downloads section of http://www.componentone.com[^].
Suelinda W
Customer Engagement, ComponentOne LLC
|
|
|
|
|
Hi!
I have an application with two AppDomains (say A and B) where an object X that lives in AppDomain A is passed to AppDomain B where a method subscribes for an event of object X. This means that when object X fires its event, the delegate is called over AppDomain boundaries. This works well as long as the method the event-delegate points to (in AppDomain B) is public. If the method is anything but public (e.g. internal, private or protected) I get an SerializationException saying that it the serialization does not serialize delegates pointing to non-public members.
I find this strange and annoying as I don't want to make the method in question public.
Any suggestions? Thanks in advance
Regards,
Andre Loker
|
|
|
|
|
While it may be annoying, it certainly isn't strange. When crossing application boundaries (including distinct AppDomains), .NET Remoting marshals the call to another context, similar in concept (regarding this discussion) to your code calling another class's code. Depending on derivation and location, the method must be public in order to call it.
If you absolutely don't want to make it public, there is a way although it is difficult. You can extend RealProxy and the ProxyAttribute (with which you attribute your class that defines the handler). The RealProxy derivative can catch method calls (as well as other types), which you can use to override the default behavior so that the delegate is serialized. It's tricky, and if you're not too familiar with .NET Remoting I suggest you pick up a book like "Microsoft .NET Remoting" from MS Press[^] or "Advanced .NET Remoting" from Ingo Rammer[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
I am trying to print out a datagrid, and I have code that works fine, but it won't print the data in sorted order if it has been sorted in the datagrid. It still prints the original order. How can I access the rows in sorted order instead of in the original order? theTable.Rows[i] is what I've been using to loop through the rows, but is there anything else I can use so that I can print the grid sorted.
Thanks,
Blake
|
|
|
|
|
DataTable.Rows will always present the original order, but you can use a DataView to sort and get the sorted order of the contained DataRow s. You can do this like so:
DataView view = new DataView(myDataTable);
view.Sort = "myIDColumn";
foreach (DataRowView rowView in view)
Console.WriteLine(rowView.Row.ItemArray); You should be able to get this using theTable.DefaultView , which should return the DataView in its current state that the DataGrid used to sort or filter the data.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hi all. Does anyone know if the .Net databound web controls use DataBinder.Eval(objDataItem, sPropName) for determining field values from data sources? For example, does a DropDownList control use DataBinder.Eval to evaluate its DataTextField and DataValueField properties at run-time?
|
|
|
|
|
DataBinder.Eval uses reflection to data-bind your expression against an object. So, when you commonly see DataBinder.Eval(Container.DataItem, "SomeProperty") reflection is used to find the "SomeProperty" property of the container's current data item (while declared as an Object , it's Type is whatever type is data-bound, like a list or a DataTable . The ListControl.DataTextField and ListControl.DataValueField are used by the overridden OnDataBinding event handler while enumerating the DataSource (with regard to the DataMember ) to get the current data item's property. If you use ildasm.exe, you can see that DataBinder.GetPropertyValue is actually used in this case.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hi,
Can anyone tell me how a web service would get the calling computers IPAddress? I'm new to web services and I'm not sure where to look for this type of information. It's probably something really obvious that I'm unaware of.
Thanks
|
|
|
|
|
Domain Name Services, or DNS. This is all handled by the TCP/IP stack on your machine. This is what resolves names like www.codeproject.com to IP addresses like 209.171.52.99.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath,
I looked at the Dns class, but I didn't see anything obvious that would help me find out the calling computers ip address of my web service. Is their a way to do this?
Thanks
|
|
|
|
|
You can use Dns.GetHostByName (or the asynchronous BeginGetHostByName ) to get the IP address, but you don't need to in most cases. When the proxy makes a request to the remote Web Services via its URL, the DNS client of your local machine will resolve the IP address, connect to the server, and make the request on the Web Service. This is all done internally - you do not need to resolve the IP address manually, just like you don't need to use the IP address in Internet Explorer and other Internet-ready applications.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
So all I need to do is add this code to my web service and this will get the calling programs ip address?
string sHostName = Dns.GetHostName();<br />
IPHostEntry ipEntry = Dns.GetHostByName( sHostName );<br />
string sCallingAppName = ipEntry.HostName;
Thanks
|
|
|
|
|
If you want to log the IP address of the machine making the request to your web service, all you need to do us is get Context.Request.UserHostAddress inside a method call in your web service (Context is a property inheritted from the WebService from which your web service derives).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks so much for your help, this is exactly what I needed.
|
|
|
|
|
We have a beta .NET/C# application that we release every couple for client computers to install. They install it over their previous version.
We are finding that there are multiple entries in the Add/Remove Programs section even though there is only one installation on their machine - I assume that there is one entry per upgrade.
Any way to avoid this without manually removing the excess entries from the Add/Remove Programs?
|
|
|
|
|
Make sure in your installer project you set RemovePreviousVersion is set to True and always keep the UpgradeCode the same. To fix any current problems, you can use Orca (from the Windows Installer SDK) to add the necessary entries to the Upgrade table in your installer package (.msi file). See the Windows Installer SDK on MSDN[^] for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi!
I read some articles about P/Invoke and how to call Win32 API functions.
Now I wonder: when does the runtime load the DLLs and when does it free it?
Does it load the DLL when the external function is needed and frees it immediately after calling (so many calls to the external function would be slow and the DLL couldn't "remember" anything), or does it load the DLL one time and there is no manual way to control this (i.e. we can assume the DLL is loaded and we have no way to release the DLL ourself, the DLL could remember things like global variables in it set by the .NET program).
Thanks in advance,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
The runtime loads the DLLs when the P/Invoke method is called. The proc address is found only once, which implies that the DLL remains loaded. I do a lot of interop (one could say it's my forte') and maintaining state has never been a problem.
Note that if you want to load and unload native DLLs you can always P/Invoke LoadLibrary(Ex) , GetProcAddress , and FreeLibrary .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
when i do this:
string unicodeString = "This string contains the unicode character";
// Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
// Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString);
// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
and I try to convert a Hebrew string to ascii I got in the asciiBytes
the number 69 (equals to '?')
but in english it's work just fine.
What is the problem?
Thank you in advanced,
Eran.
|
|
|
|
|
You have to use the Hebrew codepage. See Encoding.GetEncoding .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
What I want to do is have a background image on my tabpage that does not move when the tabpage's scrollbar is moved.
Right now what I am doing is in the tabpage's paint method I am drawing the bitmap:
pe.Graphics.DrawImage(bmpTabBack,0,0);
I have overriden WndProc and when I get a WM_VSCROLL message I do:
Invalidate(false);<br />
Update();
This does keep the background image in one place but there is some flickering if you move the scrollbar up/down really fast.
Is there another method that I can use to make it so that the background image never moves and there is no flickering?
Thanx for the help,
-Flack
|
|
|
|