|
Hello,
I have a tab control on my main form and my form has an image as its background.
Is there any way for me to have the tabpages be transparent so that you can see the forms background image behind it? It works with my buttons but not with the tabpages.
I tried:
BackColor = Color.Transparent; but that didnt do anything.
If anyone can help me out that would be great
Thanx,
-Flack
|
|
|
|
|
The .NET TabControl is actually a wrapper of the "PropertySheet" control that first appeared in the Common Control Library Version 4.71. It is not a "Windowless" control that you can just make transparent by setting some flag. What you can do is to trick the user's eye into thinking that the TabPage is transparent by drawing the portion of the Form's background image underneath the TabPage. This will make the TabPage --not the TabControl-- seem like it has a transparent background.
Out of my own curiosity I just spent a mere 5 minutes putting together a sample that does this.
Here is the code I used on the Paint handler for one of the TabPages:
private void tabPage2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Image backImage = BackgroundImage;
TabPage tp = (TabPage)sender;
if ( backImage != null )
{
Graphics g = e.Graphics;
Rectangle tabPageBounds = tp.Bounds;
Rectangle screenTabPageBounds = tp.RectangleToScreen(tabPageBounds);
Rectangle finalRect = RectangleToClient(screenTabPageBounds);
g.DrawImage(backImage, new Rectangle(0, 0, tp.Width, tp.Height),
finalRect.Left, finalRect.Top, finalRect.Width, finalRect.Height, GraphicsUnit.Pixel);
}
}
This probably could be improved but it is something just off the top of my head.
Here is a picture of what the result looks like --not perfect but perhaps close to what you are looking for--.
Transparent TabPage
Regards,
Carlos H. Perez.
|
|
|
|
|
Thanx for the help Carlos.
I have another question now.
If my tabpage had a scroll bar, and I still wanted a transparent effect, is my only option to redraw the image each time the user scrolls?
That is what I just tried and it seems like a lot of calls to redraw the image.
Is there any other, more efficent way?
Again, thanx for the help,
-Flack
|
|
|
|
|
I'd like to switch my program's data from an XML file to a SQLite database, mostly just to mess around with it.
Does anyone have any experience with this? I couldn't find any articles on it here so I'm looking for some kind of helpful article.
|
|
|
|
|
I have the following code in a serializer class for serializing a collection:
public override object Serialize(IDesignerSerializationManager manager, object value)
{
object codeObject = GetBaseSerializer(manager).Serialize(manager, value);
CodeStatementCollection csc = (CodeStatementCollection)codeObject;
PropertyDescriptor pagesProp = TypeDescriptor.GetProperties(value)["Pages"];
PageCollection pages = (PageCollection)pagesProp.GetValue(value);
string componentName = manager.GetName(value);
foreach(GenericPage page in pages)
{
MessageBox.Show("Found Page");
CodeThisReferenceExpression thisRef = new CodeThisReferenceExpression();
CodePropertyReferenceExpression propRef = new CodePropertyReferenceExpression(thisRef, "Pages");
CodeFieldReferenceExpression childRef = new CodeFieldReferenceExpression(thisRef, manager.GetName(page));
CodeMethodInvokeExpression invokeExpr = new CodeMethodInvokeExpression(propRef, "Add", childRef);
csc.Add(invokeExpr);
}
return codeObject;
}
private CodeDomSerializer GetBaseSerializer(IDesignerSerializationManager manager)
{
return (CodeDomSerializer)manager.GetSerializer(typeof(Wizard).BaseType, typeof(CodeDomSerializer));
}
I have a designer verb that when clicked, instantiates a CollectionEditor. If I add items to the collection editor, when I hit OK, all the code necessary to create the items is serialized (I.E. new is called, things like page1.Location, etc.), EXCEPT at the bottom, where I should see MyControl.Pages.Add(page1);. Then when I open the editor again, no items appear in the collection, but the editor is apparenly aware of them, because if I added 3 pages before, then hit add in the editor, the next item will be called page4. Any ideas?
I DID notice that even though I might have added 3 pages, if I add in a check for pages.Count after the pages varialbe has been initialized, I get 0 pages.
Thanks in advance.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|
|
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
|
|
|
|