|
i need to know background programming, how can a process run in background and, it doesnt need click to run
|
|
|
|
|
You would typically write it as a Windows Service (assuming that it's the AV that you are talking about here).
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Cool score of 1
Does that mean, that there are questions which shouldn't be asked? That would be very strange!
SkyWalker
|
|
|
|
|
Just remember curiosty kills the cat. Or in these days the cat get skinned, tared and feathered, and thrown in jail with a big guy named Bubba.
Programmer: A biological machine designed to convert caffeine into code. * Developer: A person who develops working systems by writing and using software.
[ ^]
|
|
|
|
|
I am printing some text in my print preview. It prints perfectly fine. Now what i want is to get the Y position of the last chacacter of the string. Once i get the Y position of the last character I want to add some more characters on the postion of (Y+10). Is that posible to do. I would appreciate your favor.
For instance:
This is the my frist string. (I want to get the "." position). If lets say "." is 50.
I want to add a new line base on the Y postion of the "." so it's gonna be 50+10 for me to add next set of string on the position
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
int charactersOnPage = 0;
int linesPerPage = 0;
e.Graphics.MeasureString(stringToPrint, this.Font,
e.MarginBounds.Size, StringFormat.GenericTypographic,
out charactersOnPage, out linesPerPage);
e.Graphics.DrawString(stringToPrint, this.Font, Brushes.Black,
e.MarginBounds, StringFormat.GenericTypographic);
stringToPrint = stringToPrint.Substring(charactersOnPage);
e.HasMorePages = (stringToPrint.Length > 0);
}
|
|
|
|
|
MeasureString on the Graphics object will tell you how many pixels the string will take up, so you can work it out from there.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've tried for a while to get a progressbar embedded within a listview, but just have one problem. If you resize the column that the progressbar is in so that it can fill the whole row, then the progressbar doesn't resize correctly when the scrollbar is moved. See the picture below. This only happens for columnindex > 0
This is the code I am using
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if (e.Item.GetType() == typeof(MyListViewItem))
{
MyListViewItem item = (MyListViewItem)e.Item;
if (item.Bars.ContainsKey(e.ColumnIndex))
{
e.DrawDefault = false;
if (e.ColumnIndex > 0)
{
int runningTotal = 0;
for (int i = e.ColumnIndex - 1; i >= 0; i--)
{
System.Diagnostics.Debug.WriteLine(e.ColumnIndex);
runningTotal += this.Columns[i].Width;
}
runningTotal += e.Item.Bounds.Left;
item.Bars[e.ColumnIndex].Location = new System.Drawing.Point(runningTotal, e.Bounds.Location.Y);
item.Bars[e.ColumnIndex].Width = this.Columns[e.ColumnIndex].Width;
item.Bars[e.ColumnIndex].Height = e.Bounds.Size.Height;
}
else
{
int clientBound = e.Item.Bounds.Left;
item.Bars[e.ColumnIndex].Location = new System.Drawing.Point(clientBound, e.Bounds.Location.Y);
item.Bars[e.ColumnIndex].Width = this.Columns[e.ColumnIndex].Width;
item.Bars[e.ColumnIndex].Height = e.Bounds.Size.Height;
}
}
else
e.DrawDefault = true;
}
else
e.DrawDefault = true;
base.OnDrawSubItem(e);
}
I have also overridden "OnColumnWidthChanging" to resize the bars when the column width changes, and also overridden WndProc to try and catch the scrollbars being moved, although that didn't work, so I'm assuming the problem lies in the code section for if(e.ColumnIndex > 0)
Thanks in advance ~ Jamie
P.S. - the image. The scrollbar should be in the "newcol" column.
http://img.photobucket.com/albums/v635/slugonamission/Problem.jpg
|
|
|
|
|
Hi Jamie
I'm not sure what's wrong with your current code, but have you look at this article[^]? It shows how progress bars can be embedded in a custom list view, so it seems applicable.
|
|
|
|
|
How to do this.
When I enter some number (ASCII code of some character) in textBox, in other textBox to appear the character.
Exp: 97 => a
118 => v
65 => A
and so on.
Vasildb
|
|
|
|
|
Handle the TextChanged event of the first textbox. In the handler write:
ushort value;
if(ushort.TryParse(InputTextBox.Text, out value))
{
OutputTextBox.Text = Encoding.ASCII.GetString(new byte[] { value});
}
else
{
OutputTextBox.Text == "";
}
-- modified at 16:38 Thursday 4th January, 2007
PS.
1- char Datatype is unicode actually. So it could accept values outside the Ascii range.
2- MessageBoxes and TextBoxes are incapable of displaying all the Ascii characters. Some are inprintable and would display a different value. To fully display all printable Ascii characters you would need a console.
Regards
|
|
|
|
|
You would just need to use the "TextChanged" event of the textbox, then if the entered number(s) fall within the range for an ASCII character, cast the integer to char.
Something like this would work.
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox2.Text = string.Empty;
string text = string.Empty;
string[] chars = textBox1.Text.Split(' ');
foreach (string str in chars)
{
if (str.Length > 0)
{
int num = Convert.ToInt32(str);
textBox2.Text += (char)num + " ";
}
}
}
|
|
|
|
|
But if I enter a char the program will falls.
How to eliminate this.
Vasildb
|
|
|
|
|
The other solution was better.
Instead of Convert.ToInt32, use int.TryParse to see if it's a number. Or make the text box accept numbers only.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi i want to sent the cursor from one textbox to another textbox or button just pressing ENTER key all time. but i am not getting any way so that i can perform this job which i can do very easily in vb just using keypress event and keyenter(keyascii). i will be grateful if somebody sent me this solution zelane
|
|
|
|
|
1- Handle the TextBox.KeyDown event.
2- In the handler call NextTextBox.Focus() method;
Regards
|
|
|
|
|
i am new in C# so that can't understand how to get help from your hints. request u to explain a little. showing just two textbox (like textbox1 and textbox2)
|
|
|
|
|
Alright! I guess atleast you know the PropertiesGrid, right?
1- Select TextBox1. Open PropertiesGrid. Open Events tab -little lightning button to the top-. DoubleClick on KeyDown event.
2- The code should show. Add these lines
if (e.KeyData == Keys.Enter)
TextBox2.Focus();
3- Err... That's it!
Regards
|
|
|
|
|
adding to what Nader said,
you can further fine-tune by querying TabStop and TabIndex properties of the
text boxes (controls where applicable) and compare TabIndex to dynamically set focus to the control which is next in the TabIndex order.
regards.
|
|
|
|
|
I want to implement a progressbar that indicates the progress of a thread going on
I've got a
public void F1(Object o)
which has the thread body
and a button which start the thread
and when I want to make things like
progressBar1.Maximum = 100;
in the F1 a get a cross-thread error
can anyone help?
|
|
|
|
|
Sure. Controls are not thread safe. You should use Invoke to update your progressbar:
1- Make a method in your form that has the progressbar. Let's say
public void UpdateProgress(int NewPosition)
{
MyProgressBar.Value = NewPosition;
}
2- Declare your delegate in the form:
public delegate void MyDelegate(int NewPosition);
3- Now in your Thread, just invoke it like this:
public void MyThreadMethod()
{
MyDelegate MyProgressDelegate = new MyDelegate(UpdateProgress);
Invoke(MyProgressDelegate, new object[] { 10 });
Invoke(MyProgressDelegate, new object[] { 20 });
Invoke(MyProgressDelegate, new object[] { 30 });
}
Regards
|
|
|
|
|
Hi,
I didn't know where I should post this, but because it is in C# I thought this would be the best place, even though it is ADO.NET stuff.
Anyway, I have a question, I have created a datasource to the northwind database and created a simple windows form. With the first name, last name textboxes etc. and to select the employees I use the listbox with the employees last names in it. I have added an the TextBox_Validate Event to each textbox with the code:
private void TextBox_Validated(object sender, EventArgs e)<br />
{<br />
employeesTableAdapter.Update(northwndDataSet1.Employees);<br />
<br />
employeesTableAdapter.Fill(northwndDataSet1.Employees);<br />
}
Yet, when I change a name, and then tab or click somewhere else, it doesn't update the database with the new name.
What am I doing wrong?
Thanks,
Any reply is appreciated
|
|
|
|
|
I've used ADO myself for sometime and have seen alot of errr.... Surperises you'd call them?!
Anyway, I'm sure the code is called, and that it's excuted without errors. From your code it looks like you've used the designer. Why didn't you use it to make the textboxes. It would update them automatically using a DataNavigator?
Regards
|
|
|
|
|
Blekk wrote: What am I doing wrong?
It would appear you did not look at the MANY database articles here on CodeProject. Give it a shot, I imagine it will help.
led mike
|
|
|
|
|
Hi,
I wish to have a magnify function in my program (C#) to view the form,
like that program in Windows XP (/Accessories/Accessibility/Magnifier).
How do I get the forms current view (appearance), and how do I show that in another form?
Can anyone help out?
Thanks in advance!
Gywox
|
|
|
|
|
1- Get current mouse position using Form.MousePosition property
2- Copy the area of the screen you desire using Graphics.CopyFromScreen()
3- scale it using Graphics.Scale() method.
3- Draw it into a Bitmap
4- View the bitmap in the other form inside a PictureBox for example.
Regards
|
|
|
|