|
Yes, but if Browseable is set to false, it doesn't serialize out to XML. So what I need is a way to hide a property from the property grid without using the browseable attribute, or a way to change the browseable attribute dynamically before the item is saved..
|
|
|
|
|
Not sure why Browseable affect serialization... but well..
Some idea, overwrite attribute before you serialize or deserialize. May not work as the property wasn't set to Ignore.
XmlAttributeOverrides[^]
Another way is to use an interface for the property grid, where unwanted property are left out in the interface.
modified on Tuesday, December 25, 2007 1:11:55 AM
|
|
|
|
|
Hi,
i'vw copied some of MS code form msdn about how to print
but it always prints 2 pages only and BLANK
WHAT is going on
this is the code
<br />
<br />
private void printToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
ofdScenario.Filter = "Text Files|*.txt";<br />
if (ofdScenario.ShowDialog() == DialogResult.OK)<br />
{<br />
if (ofdScenario.FileName != "")<br />
{<br />
try<br />
{<br />
prntDoc.DocumentName = ofdScenario.FileName;<br />
srAppUtility = new StreamReader(prntDoc.DocumentName);<br />
prntPreview.Document = prntDoc;<br />
prntPreview.ShowDialog();<br />
prntDoc.Print();<br />
}<br />
catch (Exception E)<br />
{<br />
MessageBox.Show("printToolStripMenuItem_Click");<br />
MessageBox.Show("Error Occured while Printing \nError Message :" +<br />
E.Message, "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}<br />
finally<br />
{<br />
<br />
srAppUtility.Close();<br />
}<br />
<br />
}<br />
}<br />
}<br />
private void prntDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)<br />
{<br />
#region Inner Defenitions<br />
<br />
float linesPerPage = 0;<br />
float yPos = 0;<br />
int count = 0;<br />
float leftMargin = e.MarginBounds.Left;<br />
float topMargin = e.MarginBounds.Top;<br />
string line = null;<br />
<br />
#endregion<br />
<br />
linesPerPage = e.MarginBounds.Height/printerFont.GetHeight(e.Graphics);<br />
<br />
while (count < linesPerPage &&<br />
((line = srAppUtility.ReadLine()) != null))<br />
{<br />
yPos = topMargin + (count * printerFont.GetHeight(e.Graphics));<br />
e.Graphics.DrawString(line, printerFont, Brushes.Black, leftMargin, yPos, new StringFormat());<br />
count++;<br />
}<br />
<br />
if (line != null)<br />
e.HasMorePages = true;<br />
else<br />
e.HasMorePages = false;<br />
<br />
}<br />
Have Fun
Never forget it
|
|
|
|
|
half-life wrote: yPos = topMargin + (count * printerFont.GetHeight(e.Graphics));
e.Graphics.DrawString(line, printerFont, Brushes.Black, leftMargin, yPos, new StringFormat());
i think problem is in "StringFormat()", you didnt defined some String formats properties
StringFormat PageStringFormat = new StringFormat();
PageStringFormat.Trimming = StringTrimming.Word;
PageStringFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
try this StringFormat, i hope it should work
Becoming Programmer...
|
|
|
|
|
THANKS
it works
Have Fun
Never forget it
|
|
|
|
|
glad to know
Becoming Programmer...
|
|
|
|
|
hi
i create a userControl and inheritance it from TextBox control, i was override OnTextChanged event as follow(to change codpage of numbers to arabic):
protected override void OnTextChanged(EventArgs e)<br />
{ <br />
this.Text = this.ToArabicNumber(this.Text); <br />
}
and my method (ToArabicNumber) is here:
private string ToArabicNumber(string text)<br />
{<br />
char[] chars = new char[text.Length];<br />
chars = text.ToCharArray();<br />
StringBuilder sb = new StringBuilder();<br />
foreach (char c in chars)<br />
{<br />
if (char.IsDigit(c))<br />
{<br />
sb.Append(Strings.ChrW(Strings.AscW(c) + 1728).ToString());<br />
}<br />
}<br />
return sb.ToString();<br />
}
my problem is that in runTime, when i enter any value to my custom textBox, it's Text changed and fire OntextChanged event and change codpage to arabic and then fire OntextChanged and so on (Unlimited loop),
how to solve my problem ?
thanks
|
|
|
|
|
hdv212 wrote: how to solve my problem ?
If the text is already an arabic number, then don't set the text.
protected override void OnTextChanged(EventArgs e)
{
string arabicNumber = ToArabicNumber(Text);
if (Text != arabicNumber)
Text = arabicNumber;
}
|
|
|
|
|
thanks for reply
but my problem is that when i change TextBox.Text in onChangedText, the onChangedText event fire again and so on (Unlimited loop), like this :
TextBox.Text(onChangedText fired) -> ChangeToArabic(onChangedText fired)
-> ChangeToArabic(onChangedText fired) -> ChangeToArabic(onChangedText fired) -> ChangeToArabic(onChangedText fired)-> ...
how to solve this problem ?
|
|
|
|
|
hdv212 wrote: thanks for reply
but my problem is that when i change TextBox.Text in onChangedText, the onChangedText event fire again and so on (Unlimited loop)
Are you suggesting that I gave you a solution that loops infinitely? If you can show where my solution loops infinitely then I'll accept that you still have a problem. If not, then what is your problem?
Please look at my solution. It is very simple. It does loop but once. The reason it only loops once is that I have a condition that stops it looping more than that.
So, my question to you: Did you try my solution before complaining that I don't solve it? Looking at the way you phrased your follow up post, you are basically saying I did not understand your original problem, which implies that you didn't attempt to implement my solution. This suggest that IN FACT you did not understand my solution, rather than me not understand your problem.
|
|
|
|
|
thanks Colin Angus Mackay
i tested your suggestion way, but it is not help me, because when i add new character in my textBox(and fire OnTextChanged event) my new text different with old text that i converted to arabic numbers.
|
|
|
|
|
hdv212 wrote: i tested your suggestion way, but it is not help me
Bit it no longer loops infinitely. Right?
hdv212 wrote: because when i add new character in my textBox(and fire OnTextChanged event) my new text different with old text that i converted to arabic numbers.
Then you need to capture the selection before changing the text, then put the selection back afterwards. In a text box a selection can have zero length which representst the position the cursor is at.
|
|
|
|
|
Hi,
Here iam using windows applicatio,and i have one timer control,here i need to give timercontrol interval value in Config File.
How can i do this?
Vasvai
|
|
|
|
|
Well, you get yourself a StreamReader, pass the path to your config file and start reading.
Say you had your config file setup like this:
name="bob"
interval=20
age=86
You could use something like:
StreamReader SR = new StreamReader("myConfigFile");
do {
string[] line = SR.ReadLine().Split('=');
string variable = line[0];
string value = line[1];
switch(variable) {
case "interval":
myTimer.Interval = Convert.ToInt32(value);
break;
}
if(SR.Position == SR.Length)
break;
}while (true);
Just to give you an idea.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
hi there,
i want that my application should run once at a time, like some softwares/programs (for example : windows default picture viewer)
so to i do that i did it like this :(in Main())
string name = Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf(@"\") + 1).ToLower().Replace(".exe","");
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName(name);
if (p.Length != 0)
{
Application.Exit();
return;
}
but i dont like this way, anyone know any other good way?
thanks
Becoming Programmer...
|
|
|
|
|
i dunno what happened but "edit and delete" buttons arent showing in the post,
so here is the original post that not appearing correct (above) :
hi there,
i want that my application should run once at a time, like some softwares/programs (for example : windows default picture viewer)
so to do that i did it like this in Main())
string name = Application.ExecutablePath.Substring(Application.ExecutablePath.LastIndexOf(@"\") + 1).ToLower().Replace(".exe","");
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName(name);
if (p.Length != 0)
{
Application.Exit();
return;
}
but i dont like this way, anyone know any other good way?
thanks
Becoming Programmer...
|
|
|
|
|
|
my way is short than it, xD
Becoming Programmer...
|
|
|
|
|
So what? Shorter doesn't mean better. What if your executable is renamed? Your code won't work.
|
|
|
|
|
yeah i know, thats why i asked here... so i'll use mutex because it will work when application renamed.
thanks
Becoming Programmer...
|
|
|
|
|
You are welcome
|
|
|
|
|
Your code may be shorter, but it certainly isn't better. The right way to do this is using a mutex which you can guarantee will be unique to your application and doesn't depend on the process name. There are also solutions other than the one presented in the article, but they all work basically the same way. Search for the words "c# single instance application" and you should find a lot more examples.
|
|
|
|
|
That's correct, a Mutex is probably the most simple and correct way to ensure a single instance.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi All
i am trying to override the PreProcessMessage for the form
and i am using this code
public override bool PreProcessMessage(ref Message msg)
{
switch (msg.Msg)
{
case WM_RBUTTONDOWN: return true;
default: return base.PreProcessMessage(ref msg);
}
}
but this code never been called
i am wondering, why ?
|
|
|
|
|
Do you call the code yourself? If not then i can't see you being able to get the return value from it. Are you sure you don't mean to override WndProc?
My current favourite word is: Bauble!
-SK Genius
|
|
|
|