|
this must be in recursive method...else the textboxes in container controls will not be effected
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
this is what you want is;
foreach (Control txt in this.Controls)
if (txt is TextBox)
((TextBox)txt).ReadOnly = true;
|
|
|
|
|
Wouldn't that be txtTextBox1.ReadOnly = txtTextBox2.ReadOnly = True ; ?
|
|
|
|
|
Thanks everyone!
Yup, I'm a NEWB
|
|
|
|
|
Hi
i have a form and i inserted a gif image to it's resx file (local resource). now, i want to retrieve it and display to picturebox, for this, i wrote this code :
this.pictureBox1.Image = Image.FromStream(this.GetType().Assembly.GetManifestResourceStream("MyAppNamespace.Form1.wait1.gif"));
but the following error message shown me :
Value of 'null' is not valid for 'stream'.
where does my problem and how to solve it ?
Thanks
|
|
|
|
|
Why don't you just do this?
this.pictureBox1.Image = Properties.Resources.wait1.gif;
Kristian Sixhoej
"You can always become better." - Tiger Woods
|
|
|
|
|
Hi Kristian
Your suggesstion is for global resource wheras in my situation is local resource (for example: Form1.resx file)
|
|
|
|
|
Hi,
hdv212 wrote: where does my problem and how to solve it ?
If you put all the action in one big line of code you can be sure of two things:
1. if there are any problems, they will be in that one line;
2. it will be difficult to debug.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:28 AM
|
|
|
|
|
Hi Luc
You mean which i wrote this code :
System.IO.Stream stream= this.GetType().Assembly.GetManifestResourceStream("DevExpressLoadingTest.Form1.resources.wait1.gif");
this.pictureBox1.Image = Image.FromStream(stream);
|
|
|
|
|
How about:
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("wait1.gif")));
I think that would work. And the chances are that in the code you have now "MyAppNamespace.Form1.wait1.gif" is incorrect, although I 'm not sure what it should be if that is the case.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Thanks SK Genius
i was tried your suggesstion like this :
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("wait1.gif")));
it's no coused error, but does not show show image. when i trace my code, i saw that this.pictureBox1.Image is null.
|
|
|
|
|
I want to place a MDI form at a certain position in relation to the MDI background application window.
Ie. When I display a certain form I would like to display the form on the right of the applications MDI window and locatthis child form in the top right corner.
How could I achieve this in c#.
|
|
|
|
|
In the Activate or Shown Event of the child form you could probably include code like the following:
this.Location = new Point(this.ParentForm.Width - (this.Width + 10), 0);
Of course, if you put the code in the Activate event you will want to ensure the code only executes the first time the form activates. That should get your MDI child in the ballpark of the right corner of the parent form. You might have to play around with the value you add to this.Width a little bit.
Good luck.
|
|
|
|
|
How can I know where a url gets redirected programatically?
e.g. This url:
http://scobleizer.com/feed/
redirects to the following url:
http://feeds2.feedburner.com/fastcompany/scobleizer
I am trying to read the xml document of feed. But the following lines of code:
var doc = new XmlDocument();
doc.Load(url);
will throw an exeption for the first url:
System.Net.WebException: The remote server returned an error: (404) Not Found.
|
|
|
|
|
Hey,
i want to generate a WM_DROPFILES Message and send it to a Control on my Form.
i found one sample in c++
http://groups.google.de/group/microsoft.public.platformsdk.shell/browse_frm/thread/5bbd1d67913ac2c7?hl=de&lr=&rnum=2&prev=/groups%3Fq%3Dsendmessage%2Bwm_dropfiles%26hl%3Dde%26lr%3D%26selm%3D03c301c3973d%25240433f8e0%2524a101280a%2540phx.gbl%26rnum%3D2
does anybody know how it sounds right in C# .Net 2.0?
here my trying, which doesnt work:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace DropFile
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Windows Form-Designer generierter Code
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(341, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(142, 40);
this.button1.TabIndex = 0;
this.button1.Text = "Load Image";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(860, 546);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
this.DragOver += new System.Windows.Forms.DragEventHandler(this.Form1_DragOver);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
if (FileList.Length == 1)
{
FileInfo fi = new FileInfo(FileList[0]);
if (fi.Extension == ".gif" | fi.Extension == ".bmp" | fi.Extension == ".jpg" | fi.Extension == ".jpeg")
{
e.Effect = DragDropEffects.Move;
}
}
}
else
e.Effect = DragDropEffects.None;
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
if (FileList.Length == 1)
{
FileInfo fi = new FileInfo(FileList[0]);
if (fi.Extension == ".gif" | fi.Extension == ".bmp" | fi.Extension == ".jpg" | fi.Extension == ".jpeg")
{
this.BackgroundImage = Image.FromFile(FileList[0]);
}
}
}
else
e.Effect = DragDropEffects.None;
}
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public const uint GMEM_FIXED = 0x0000;
public const uint GMEM_SHARE = 0x2000;
public const uint WM_DROPFILES = 0x0233;
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern int GlobalLock(IntPtr Handle);
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern int GlobalUnlock(IntPtr Handle);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true)]
static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam,
IntPtr lParam);
[Serializable]
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public Int32 X;
public Int32 Y;
public POINT(Int32 x, Int32 y)
{
this.X = x;
this.Y = y;
}
}
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
class DROPFILES
{
public int size;
public POINT pt;
public bool fND;
public bool WIDE;
}
public static byte[] RawSerialize(object anything)
{
int rawsize = Marshal.SizeOf(anything);
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.StructureToPtr(anything, buffer, false);
byte[] rawdatas = new byte[rawsize];
Marshal.Copy(buffer, rawdatas, 0, rawsize);
Marshal.FreeHGlobal(buffer);
return rawdatas;
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_DROPFILES)
{
bool bTest = true;
}
base.WndProc(ref m);
}
private void button1_Click(object sender, EventArgs e)
{
IntPtr hwnd = this.Handle;
DROPFILES s = new DROPFILES();
s.size = 20;
s.pt = new POINT(10, 10);
s.fND = false;
s.WIDE = false;
string file = "D:\\test.bmp\0";
Int32 filelen = Convert.ToInt32(file.Length);
byte[] bytes = RawSerialize(s);
int structlen = (int)bytes.Length;
int size = structlen + filelen + 1;
IntPtr p = Marshal.AllocHGlobal(size);
GlobalLock(p);
int i = 0;
for (i = 0; i < structlen; i++)
{
Marshal.WriteByte(p, i, bytes[i]);
Console.WriteLine("Wrote header byte " + i.ToString() + " of " + size.ToString());
}
byte[] b = ASCIIEncoding.ASCII.GetBytes(file);
for (int k = 0; k < filelen; k++)
{
Marshal.WriteByte(p, i, b[k]);
Console.WriteLine("Wrote filename byte " + i.ToString() + " of " + size.ToString());
i++;
}
Marshal.WriteByte(p, i, 0);
GlobalUnlock(p);
PostMessage(hwnd, WM_DROPFILES, p, IntPtr.Zero);
Marshal.FreeHGlobal(p);
}
}
}
thanks a lot
Steffen
|
|
|
|
|
May be you should add:
this.AllowDrop = true;
in
private void InitializeComponent()
|
|
|
|
|
Did you ever find the solution to this?
|
|
|
|
|
Hello everyone,
I am developing a Web Services based on ASP.Net asmx web service. The server end will response byte[] to client encoded in UTF-8, and client to convert the byte[] to string.
My confusion is, the England pound character at server side (I dump just before the Http response is wrote, and the character at server side is correct to be England pound) will be received as ?? from client side. I also used Fiddler at client side to monitor traffic on wire, the on wire traffic is correct to be pound.
Any ideas what is wrong? I suspect it is encoding issue, but I have no idea how to debug further and any settings (settings from client web service proxy?) which will impact?
thanks in advance,
George
|
|
|
|
|
Hi evryone
1. How can I show and print in CristalReport widthwise (in C# code) ?
2. How can I Make PDF file whith C# code ?
|
|
|
|
|
Short Answer: PdfWriter
string path = Path.GetTempPath() + Path.GetRandomFileName() + ".pdf";
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(path, FileMode.Create));
document.Open();
document.Add(new Paragraph("Karaoke Go!"));
iTextSharp.text.Font font5 = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 9);
PdfPTable table = new PdfPTable(dt.Columns.Count);
PdfPRow row = null;
float[] widths = new float[] { 6f, 6f, 1f };
table.SetWidths(widths);
table.WidthPercentage = 100;
int iCol = 0;
string colname = "";
PdfPCell cell = new PdfPCell(new Phrase("Karaoke Go"));
cell.Colspan = dt.Columns.Count;
foreach (DataColumn c in dt.Columns)
{
table.AddCell(new Phrase(c.ColumnName, font5));
}
foreach (DataRow r in dt.Rows)
{
if (dt.Rows.Count > 0)
{
table.AddCell(new Phrase(r[0].ToString(), font5));
table.AddCell(new Phrase(r[1].ToString(), font5));
table.AddCell(new Phrase(r[2].ToString(), font5));
}
} document.Add(table);
document.Close();
System.Diagnostics.Process.Start(path);
Cheers
|
|
|
|
|
|
I have 2 classes namely Client.cs and Server.cs
Each class has a main() method...
So it gives me an error:
More than one entry point
Can i call a class from another class in C#?
If so how can i do it?
|
|
|
|
|
You can never call a class, you can only call methods (ok and a few others things, too much detail..)
If they would be allowed to both have a Main, then which one would start? Should the program start out with 2 threads?
But, probably, you have 2 programs there that have to be run as 2 programs, because that's what they are. So put them in 2 different projects..
|
|
|
|
|
Actually each class may have its Main method. If you have more than one Main method you just have to specify your startup object (the class that contains the main which you want to start).
|
|
|
|
|
You're making it more complicated than it needs to be.
If you have a client and a server object, you don't want to start just one of them anyway.
|
|
|
|