|
Just try BringToFront(); method of this textbox
|
|
|
|
|
it doesn't help since the parent of the textbox used as a list is the control not the form! when BringToFront() is used it brings the textbox to the front of the control but not the form on which the contol is? currently i have a work around which changes the parent of the textbox and positions it so that it aligns with the rest of the control. it works.
the problem is i don't want to change the parent of the textbox just to draw it on top of the z-order
|
|
|
|
|
I downloaded a project in C# and would like to compile it. There is no project or solution file available, so, I created a new project and put everything there.
PROBLEM:
There are many files stored in different sub-directories (of the project directory). The files in each directory belong to the same namespace.
For example :
In Main.cs of the project directory contains:
using ABC.namespace1
using ABC.namespace2
and in the directory {project dir}/ABC/namespace1, there is a bunch of class files declaring as: namespace ABC.namespace1
MY QUESTION:
Do I need to copy all the files of the sub-directories to the project directory to compile it or there is a setting in Visual Studio that allows this. Right now, when I tried to compile it, I got the message:
"The type or namespace name 'namespace1' does not exist in the class or namespace ABC. Are you missing assembly references ?"
Thanks a lot for any help
|
|
|
|
|
It may be a .dll with it and then you may have a reference first to it.
|
|
|
|
|
i want to write to program for uploading file to webserver, but i don't know the mechanism of uploading file
Show me detail if you can
Thank you
|
|
|
|
|
You could use something simple like the following:
WebClient <code>Client</code> = new WebClient();
Client.UploadFile("http://www.MyWebsite.com/index.aspx", "C:\MyFile.aspx");
Note: You should also consider providing checkups for your upload mechanism (such as checking if the file does exist, or that its contentLength is greater zero).
Hope this helps
Regards,
Polis
Can you practice what you teach?
|
|
|
|
|
Hi,
Should I use TableLayoutPanel for my Form with FixedDialog style?
I can't understand when i need in TableLayoutPanel.
Best regards.
|
|
|
|
|
You should use TableLayoutPanel when you want your controls laid out in rows and columns.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
Hi,
I want to ask how to execute a static function in a user created application domain. I am trying to run following sample code. But it seems that the method that I am trying to execute in my created domain always executed in the default created domain (caller domain).
public void ExitProcessTest()
{
string applicationTitle = "ApplicationToBeKilled";
Assembly asm1 = Assembly.GetAssembly(typeof(OSP.Forms.ErrorBox));
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = @"file:///C:\Components.NET\Testing\TestProject\bin\Debug\";
ads.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory;
ads.ApplicationName = applicationTitle;
AppDomain newappDomain = AppDomain.CreateDomain(applicationTitle, null, ads);
Assembly asm = newappDomain.Load(asm1.FullName);
Type type = asm.GetType("OSP.Forms.ErrorBox");
type.InvokeMember("ExitProcess", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { applicationTitle });
Thread.Sleep(15000);
}
public static void ExitProcess(string applicationTitle)
{
//It's better to close the application, otherwise, could throw many other errors
try
{
ApplicationTitle = applicationTitle;
Thread exitThread = new Thread(new ThreadStart(ApplicationExitThread));
exitThread.Name = "ExitThread";
exitThread.Start();
}
catch (Exception exc) { ShowError(exc, "Osp.Shared", null, "script_error@etb.bel.alcatel.be"); }
}
private static string ApplicationTitle;
private static void ApplicationExitThread()
{
try
{
Form f = new Form();
f.TopMost = true;
f.Size = new Size(370, 60);
f.BackColor = Color.Red;
f.FormBorderStyle = FormBorderStyle.None;
Label lbl = new Label();
lbl.BorderStyle = BorderStyle.FixedSingle;
lbl.ForeColor = Color.White;
lbl.Font = new Font("Verdana", 10, FontStyle.Bold);
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Dock = DockStyle.Fill;
lbl.Text = "The " + ApplicationTitle + " will exit in few seconds.\nSorry for the inconvenience.";
f.Controls.Add(lbl);
f.StartPosition = FormStartPosition.CenterScreen;
f.Show();
f.TopMost = true;
f.Invalidate();
f.Update();
Thread.Sleep(1000);
for (int i = 5; i > 0; i--)
{
lbl.Text = "The " + ApplicationTitle + " will exit in " + i + " second" + (i > 1 ? "s" : "") + ".\nSorry for the inconvenient.";
lbl.Update();
Thread.Sleep(1000);//to ensure the error mail is sent!
}
//Process.GetCurrentProcess().Kill();
MessageBox.Show(AppDomain.CurrentDomain.FriendlyName);
}
catch (Exception exc) { ShowError(exc, "Osp.Shared", null, "script_error@etb.bel.alcatel.be"); }
}
|
|
|
|
|
Hey
I'm trying to find a way to get the name of a file in a FileInfo object.
I DO NOT mean this:
out of, c:\blabla.exe --GET--> blabla.exe
BUT this:
out of, c:\blabla.exe --GET--> blabla
anyone can help me with this???
|
|
|
|
|
|
Thanks!
that could really make my life easier!!! (I wrote this code in the hard way!)
|
|
|
|
|
I wrote my first own control, it derives from Windows.Forms.Control, and it's a simple ellipse label. The code for drawing:
<br />
protected override void OnPaint(PaintEventArgs pe) {<br />
Graphics g = pe.Graphics;<br />
Brush foreBrush = new SolidBrush(ForeColor);<br />
Brush backBrush = new SolidBrush(BackColor);<br />
g.FillEllipse(backBrush, ClientRectangle);<br />
<br />
StringFormat fmt = new StringFormat();<br />
fmt.Alignment = StringAlignment.Center;<br />
fmt.LineAlignment = StringAlignment.Center;<br />
g.DrawString(Text, Font, foreBrush, ClientRectangle, fmt);<br />
<br />
base.OnPaint(pe);<br />
}<br />
}<br />
The question - how to implement so that the label wraps text if it is to long to fit in a single line?
|
|
|
|
|
Hi, you can use MeasureString to give you the length of the string in drawing units (pixels) and compare the width of your control - border (or just client width if there is not an NC portion). Then of course, just extend the height of your control by the height of the current font, split, and wrap the line.
You can get the font height with the Font property and call its Height property but make sure you use your graphics object's MeasureString method to get the length of the string in question.
hope that is enough detail for you, if not let me know and i'll try to help further.
|
|
|
|
|
That'll do, thanks a lot man!
|
|
|
|
|
How to i create a website that can send sms`s ???
Thanks in advance !;)
|
|
|
|
|
You could implement a website with a server backend that sends SMS's. Search Codeproject, there are several articles (such as this one[^]) that describe how you can send SMS messages.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
these articles cannot be accessable.
|
|
|
|
|
I'm using a PropertyGrid control, and I want to display only some particular properties. I know I have to implement ICustomTypeDescriptor in my class so the grid can use GetProperties method. And that's the problem - I need only that method, but the interface is quite big, contains many methods. I know I always can write empty method implementation but to me it just doesn't seem the right thing to do. Is there another way? If not, could anyone post some piece of code which implements the GetProperties method?
|
|
|
|
|
Is there another way?
Not that I'm aware of
If not, could anyone post some piece of code which implements the GetProperties method?
public class MyDescriptor : ICustomTypeDescriptor<br />
{<br />
public TypeConverter GetConverter()<br />
{<br />
return TypeDescriptor.GetConverter(this, true);<br />
}<br />
<br />
public EventDescriptorCollection GetEvents(Attribute[] attributes)<br />
{<br />
return TypeDescriptor.GetEvents(this, attributes, true);<br />
}<br />
<br />
EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents()<br />
{<br />
return TypeDescriptor.GetEvents(this, true);<br />
}<br />
<br />
public string GetComponentName()<br />
{<br />
return TypeDescriptor.GetComponentName(this, true);<br />
}<br />
<br />
public object GetPropertyOwner(PropertyDescriptor pd)<br />
{<br />
return this;<br />
}<br />
<br />
public AttributeCollection GetAttributes()<br />
{<br />
return TypeDescriptor.GetAttributes(this, true);<br />
}<br />
<br />
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)<br />
{<br />
PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(this, attributes, true);<br />
<br />
PropertyDescriptor[] pd = new PropertyDescriptor[x];<br />
<br />
for (int i=0; i<pdc.Count; i++)<br />
{<br />
if (pdc[i].Name.Equals("Property1"))<br />
{<br />
pd[0] = pdc[i];<br />
}<br />
else if (pdc[i].Name.Equals("Property2"))<br />
{<br />
pd[1] = pdc[i];<br />
}<br />
...<br />
}<br />
<br />
return new PropertyDescriptorCollection(pd);<br />
}<br />
<br />
PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties()<br />
{<br />
return ((ICustomTypeDescriptor) this).GetProperties(new Attribute[0]);<br />
}<br />
<br />
public object GetEditor(Type editorBaseType)<br />
{<br />
return TypeDescriptor.GetEditor(this, editorBaseType, true);<br />
}<br />
<br />
public PropertyDescriptor GetDefaultProperty()<br />
{<br />
return TypeDescriptor.GetDefaultProperty(this, true);<br />
}<br />
<br />
public EventDescriptor GetDefaultEvent()<br />
{<br />
return TypeDescriptor.GetDefaultEvent(this, true);<br />
}<br />
<br />
public string GetClassName()<br />
{<br />
return TypeDescriptor.GetClassName(this, true);<br />
}<br />
}<br />
|
|
|
|
|
Thanks a lot! One more question - the class that implements the ICustomTypeDescriptor is the class I will be forwarding to tge PropertyGrid right? Sorry if this is a supid question...
|
|
|
|
|
the class that implements the ICustomTypeDescriptor is the class I will be forwarding to tge PropertyGrid right?
Yes
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
hi ,
i am trying to fetch the datafrom database into dataet and display it in a richtextbox in rtf format.
it displays a illegal file format.
please throw some light on where i am mistaken
below is the code for your reference
{
string st;
string st1 = "";
st = "select * from TPNeeds";
SqlDataAdapter ad = new SqlDataAdapter(st,con);
ad.Fill(dataset11,0,0,"TPNeeds");
DataTable dt = dataset11.Tables[0];
ArrayList arr = new ArrayList();
//Encoder e1 = Encoding.UTF8.GetEncoder();
Encoding encode = Encoding.Default;
foreach(DataRow row in dt.Rows)
{
st1 += row["NeedText"].ToString();
//richTextBox2.Rtf = encoding.GetString(binaryData,0,binaryData.Length);
}
byte[] rawBytes = Encoding.ASCII.GetBytes( st1 );
using ( MemoryStream ms = new MemoryStream(rawBytes) )
{
richTextBox2.LoadFile( ms, RichTextBoxStreamType.RichText );
}
// System.IO.MemoryStream stream = new System.IO.MemoryStream(StrToByteArray(st1));
// richTextBox2.LoadFile(stream,RichTextBoxStreamType.PlainText);
//richTextBox2.LoadFile(stream,RichTextBoxStreamType.RichText);
//richTextBox2.Rtf = encoding.GetString(bytearr,0,bytearr.Length);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
MessageBox.Show(ex.StackTrace.ToString());
}
}
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}
mrlathiwala
|
|
|
|
|
Is the data in the database a string in rich text format? Or is it a string in plain text format?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Horrific Minnesota Radio
Judah Himango
|
|
|
|
|
it's in plain text format
|
|
|
|