|
i dont get your reply please be mor especific
|
|
|
|
|
You access properties of a label trough it's name.
Label is just a class so if you know how to work with clasess I don't know why you would not know how to work with labels...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
now i understand you brother but its simple i have this problem and i dont know how to view a label at runtime like if it was in runtime i want that my lable be able to can be moved resize etc like in desing time
|
|
|
|
|
Well that is not so simple...
You will have to do a lot more work, write some code, respond to various events etc.
Maybe the best way would be to look at the source code of the SharpDevelop IDE...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
You'll have to creat a new class, inheriting from Label. You'll need to handle the MouseMove, MouseDown, and MouseUp events so your mouse tracking code can work. You'll also need to track where in your control the mouse was clicked (MouseDown event), an offset from the top-left corner of your control. It might also be helper to change the mouse cursor while the mouse is being held down.
Here's the code I wrote to do this very thing (converted from VB.NET):
public class MovableLabel : Label
{
private Point cursorOffset;
private bool moving = false;
private Cursor currentCursor;
private void MovableLabel_MouseDown(object sender, System.Windows.Forms.MouseDownEventArgs e)
{
if (e.Button == Windows.Forms.MouseButtons.Left) {
cursorOffset = e.Location;
moving = true;
currentCursor = base.Cursor;
base.Cursor = Cursors.SizeAll;
}
}
private void MovableLabel_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (moving) {
object clientPosition = base.Parent.PointToClient(System.Windows.Forms.Cursor.Position);
base.Location = new Point(clientPosition.x - cursorOffset.X, clientPosition.y - cursorOffset.Y);
}
}
private void MoveableLabel_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
moving = Flase;
base.Cursor = currentCursor;
}
}
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
how can i view a label in runtime like if i was on desing time change his propetys etc
|
|
|
|
|
Do not post the same question more than once. If you require elaboration; 1) Edit your question with your new questions, or 2) Reply to the answer for which you do not understand stating so. Regards,
Jason Pezzimenti.
If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.
|
|
|
|
|
Do not post the same question more than once. If you require elaboration; 1) Edit your question with your new questions, or 2) Reply to the answer for which you do not understand stating so.
|
|
|
|
|
I need to rip or lets say download a xhtml page from a webserver,
the problem is that i only get the source of the site and i would like also to get the dynanic part of the site.
My code so far (taken from an example), which i only get the static part of the site.
<br />
string lcUrl = url;<br />
<br />
HttpWebRequest loHttp =(HttpWebRequest)WebRequest.Create(lcUrl);<br />
<br />
loHttp.Timeout = 10000;
loHttp.UserAgent = "test";<br />
<br />
HttpWebResponse loWebResponse = (HttpWebResponse)loHttp.GetResponse();<br />
<br />
Encoding enc = Encoding.GetEncoding(1252);
<br />
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(), enc);<br />
<br />
string lcHtml = loResponseStream.ReadToEnd();<br />
<br />
loWebResponse.Close();<br />
loResponseStream.Close();<br />
return lcHtml;<br />
-- modified at 13:31 Monday 20th March, 2006
|
|
|
|
|
What 'dynamic part' are you trying to get?
If you mean the code behind, you can't.
|
|
|
|
|
no no , more like if have a tv guide site and you want to see whats on one channel ?
-- modified at 15:44 Monday 20th March, 2006
|
|
|
|
|
Well a lot depending on how consistant is the format of the site. You can use the source and find some constant word as an anchor and grab the text off the source.
Alternatively, what I had done previously was (on VB6) run a web control in the application, point it to the target URL, send a ctrl-A key and paste it on a text box / rich text box, then grab the data from the text box.
|
|
|
|
|
thanks i will take a look into it
|
|
|
|
|
I have a base-class B where I put all my slowly changing, somewhat generic stuff. On top of that I intend to have a class C : B; in words, C inherits from B.
What's the best way to build the interface(s)? I can imagine IB, so B : IB. How do I structure an interface for C? Do I build one global interface for (C : B)? or perhaps C : IC, B (but I don't really know that means, well, I could guess).
Please advise.
(Also, I suppose I could use composition, but I'm not yet fluent with that design pattern).
Thx.
|
|
|
|
|
That depends on how you want to use it. Are the functionalities of B and c good seperated? Do you always when you work on C also need the base functionality from B?
If both contents are totally seperated I would use the following:
B : IB; C: IC, B
If not:
B : IB; IBC : IB, IC; C : IBC
But again: It greatly depends on what your are actually trying to do and how the classes are logically bound together.
|
|
|
|
|
You could try reading the article Why Extends is Evil[^] by Allen Holub. It discusses a situation similar to yours. The article deals specifically with Java, but pertains to all object-oriented languages with single inheritance and multiple "interface" implementations.
In short, Holub's answer would consist of the following:
Create an interface IB .
Create a class B implementing interface IB .
Create an interface IC .
Create a class C implementing interfaces IB and IC .
Create a private member of C of type B and, in all the functions from IB , pass those requests through to B .
As an alternative, you could modify the third and fourth items in the above list to read like this:
Create an interface IC inheriting from IB .
Create a class C implementing interface IC .
I hope that helps.
|
|
|
|
|
In case I, do I ever inherit B to C (C : B), or does the private member B of C act as a proxy to inheritance?
In case II, C has to implement IB and IC, but my purpose is to code the implementation of IB in B.
Please advise.
Thx.
|
|
|
|
|
In case I, you do not have C : B . Instead, you use composition and the unity of the interfaces, the proxy to inheritance, as you say.
In case II, you still use composition. But, instead of having C : IB, IC as in case I, you have C : IC and IC : IB . But, you still implement B : IB and use it the same way as you would in case I.
Mind you, sometimes this is overkill. There are times that you can have many implementations of IB and IC or times where coupling does not matter too much because of the specialized code in B and C . In those cases, you may wish to have B : IB and C : B, IC . Just remember that, in other parts of your application/framework, that you always want to reference IB and IC rather than implementations of those interfaces.
To quote Allen Holub:Design, by nature, is a series of trade-offs. Every choice has a good and bad side, and you make your choice in the context of overall criteria defined by necessity. Good and bad are not absolutes, however. A good decision in one context might be bad in another.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I've now implemented all this. I chose the favored option:
IB {}
IC {}
B : IB
{}
C : IC
{
B _b = new B();
}
This is working well and is clear enough for what I'm doing.
thanks for your help.
|
|
|
|
|
Hi,
I created app to send form data to Word. Its working properly. But now I want send that data anywhere in the document. For example begining, end and center. Here Im not talking about align text. Acctually I want send those data to certain palces. Please Help me
the problemKreator
|
|
|
|
|
How do I set the Zoom Factor for a CrystalReportViewer to a new zoom level (i.e., 35% or 80%)? I have tried the following code, but the CrystalReportViewer still opens 100%. Any ideas?
// This is just a short example - my code will pull the value from a config setting
int zoomFactor = 50;
this.crystalReportViewer1.Zoom(zoomFactor) ;
Code Toad
"Take one line of code at a time"
|
|
|
|
|
I found it! I was able to set the new zoom factor for the Cyrstal Report by calling a method to force the new zoom factor on page load.
|
|
|
|
|
What C# code is used to determine the workgroup name for the local pc and remote pc's in a windows app. Thanks.
|
|
|
|
|
You need to P/Invoke the NetGetJoinInformation[^] function.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Please do not send questions by email. Post them to the forum, so that other users can see them, and have a chance to answer them.
hops33n wrote: Thanks for the info, but Im just starting out and still need some help. If you get a chance here is the code I have started off with so far. I copied and pasted the invoke, but its erroring out about dllimport could not be found. What I am doing is starting off making an ip/port scanner. I thought this would be a good project to get me use to programming. If you dont mind I would appreciate any help in the future you can offer if thats ok. Thanks a bunch.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Scanner
{
public class Form1 : System.Windows.Forms.Form
{
...
[DllImport("Netapi32.dll")]
static extern int NetApiBufferFree(IntPtr Buffer);
public static string GetJoinedDomain()
{
int result = 0;
string domain = null;
IntPtr pDomain = IntPtr.Zero;
NetJoinStatus status = NetJoinStatus.NetSetupUnknownStatus;
try
{
result = NetGetJoinInformation(null, out pDomain, out status);
if (result == ErrorSuccess && status == NetJoinStatus.NetSetupDomainName)
{
domain = Marshal.PtrToStringUni(pDomain);
}
}
finally
{
if (pDomain != IntPtr.Zero) NetApiBufferFree(pDomain);
}
if (domain == null) domain = "";
return domain;
}
...
You need to copy the code from the C# Signature and User-Defined Types sections of the pinvoke.net page[^] as well as the sample code.
You also need to change the GetJoinedDomain function to return the domain when the status returns NetSetupWorkgroupName , since the current code only works with domains.
You will probably also want to add a computer name parameter to the function, so that you can get the information back from other computers.
const int ErrorSuccess = 0;
public enum NetJoinStatus
{
NetSetupUnknownStatus = 0,
NetSetupUnjoined,
NetSetupWorkgroupName,
NetSetupDomainName
}
[DllImport("Netapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetGetJoinInformation(
[In,MarshalAs(UnmanagedType.LPWStr)] string server,
out IntPtr domain,
out NetJoinStatus status);
[DllImport("Netapi32.dll")]
static extern int NetApiBufferFree(IntPtr Buffer);
public static string GetJoinedDomain(string computerName)
{
if (null != computerName && 0 == computerName.Length)
computerName = null;
int result = 0;
string domain = null;
IntPtr pDomain = IntPtr.Zero;
NetJoinStatus status = NetJoinStatus.NetSetupUnknownStatus;
try
{
result = NetGetJoinInformation(computerName, out pDomain, out status);
if (ErrorSuccess == result)
{
switch (status)
{
case NetJoinStatus.NetSetupDomainName:
case NetJoinStatus.NetSetupWorkgroupName:
domain = Marshal.PtrToStringUni(pDomain);
break;
}
}
}
finally
{
if (pDomain != IntPtr.Zero) NetApiBufferFree(pDomain);
}
if (domain == null) domain = "";
return domain;
}
public static string GetJoinedDomain()
{
return GetJoinedDomain(null);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|