|
First, you're a schmuck.
Second, it won't compile.
Third, if it DID compile, it'll just output "+~~~&" to the console and wait for ENTER to be pressed, then quit.
|
|
|
|
|
Rajdeep.NET wrote: Please provide an appropriate output to this query
'appropriate output':
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
the answer - 42.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
First of all, the DLL Delete code never gets called. However, this program should output "+~~~" and wait for input. The "&int32" is apparently a little-used escape character. Or maybe it outputs "729710206" (No, I didn't run the code).
|
|
|
|
|
Hi Guys,
I am trying to print some items from a listview. I read the whole listview item in a String and then i try to see how many characters i can write on a line of the page that i want to print one :
public void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
...
float characterPerLine = e.MarginBounds.Width/printFont.GetHeight(e.Graphics);
...
}
but this is not returning me the correct number.
The question is ... how can i calculate the number of characters per line when printing?
Kind regards,
Alex
“Be the change you want to see in the world.”
|
|
|
|
|
Sooo you're dividing the width by the height of a character to get the number of possible characters?? You don't see a problem with that??
Wouldn't you divide the width the page by the width of a character to get that?? BTW, the math you've chosen only work with fixed-width fonts. It will not return an accurate value for a proportional width font (which most fonts are!)
|
|
|
|
|
Sorry , you are right , my bad.
i tried this : float characterPerLine = e.MarginBounds.Width/printFont.Size;
and it worked. but it still is not einough...
I know that i shoud devide the widith of the line with the widith of the font but there is no printFont.GetWidith in c# intelisense.
“Be the change you want to see in the world.”
modified on Tuesday, May 5, 2009 3:24 PM
|
|
|
|
|
al3xutzu00 wrote: I know that i shoud devide the widith of the line with the widith of the font but there is no printFont.GetWidith in c# intelisense.
That is a hint, I suppose...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
al3xutzu00 wrote: I know that i shoud devide the widith of the line with the widith of the font but there is no printFont.GetWidith in c# intelisense.
There is no printFont.GetWidth in C# for a very good reason. It doesn't make any sense. Since most windows fonts are proportional there is no fixed width of a character. I.e. an 'i' character is a lot narrower than a 'W'. If there is no fixed character width in a font, you can't have a method which returns the width of a character.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
as an approximation you could come up with an "äverage string" of say 100 characters,
then feed it to e.Graphics.MeasureString and get the returned Width.
if you need an (almost) exact value, you should use MeasureString for each actual string that interests you.
The "(almost)" refers to a CP article on some minor anomalies, the result being of by a few pixels.
|
|
|
|
|
Hi,
I'm making an AutoUpdater for my application. For this I have added a new project to my solution so that I get 2 executables (the main one may need to be updated).
So far I am using the XmlReader class to get information from the internet as to the latest version of the application with a list of files to download.
However, these two things are what I would like help with:
If there is a new version available then I would like to launch the Updater application and pass it the downloaded xml file (or an array of key information, whichever is easiest).
Once the updater exe has started and has it's data then I would like it to close the main exe.
Any help would be appreciated,
- Stephen
|
|
|
|
|
neoflame wrote: If there is a new version available then I would like to launch the Updater application and pass it the downloaded xml file (or an array of key information, whichever is easiest).
Proces.Start , giving the filename & path as a parameter.
neoflame wrote: Once the updater exe has started and has it's data then I would like it to close the main exe.
Loop through the currently running processes and close yours
I are troll
|
|
|
|
|
Hi All,
I want to create a list view, which is able to move up or down the selected item using a button (as we can see in VS list view column adding property box). Can someone tel me how can I do that. A simple example is much better.
Thanks lot
I appreciate your help all the time...
CodingLover
|
|
|
|
|
ListView.SelectedItems tells you what's currently selected.
ListView.Items.RemoveAt(...) and ListView.Items.Insert(...) allows you to to remove an item from one place in the list and move it to another position.
|
|
|
|
|
Yes I did something like this,
Get the selected index from the list.
Remove it from the list.
Insert in into the next index for move down, and insert into the previous index for move up
But now I've one more thing to do. Full row selected set to true, and I select one ant click up/down move. At that point selection is vanished, and user cannot see what the selection row is. Any idea about that.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Why did the selection vanish?
It might have vanished because the control lost focus, set ListView.HideSelection to false to handle this.
It might have vanished because the selected item was removed from the list, reselect the item after adding it back to the list to handle this (ListViewItem.Selected = true ).
|
|
|
|
|
Actually it doesn't work lol. I think as you said once the item is removed, the focus is lost. But I've no idea how to keep that focus on the same item. Anyone of you have any idea about that?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
listView.Focus() will give focus back to the list view, but still you'll need to reselect the item after you've added it back to the list
|
|
|
|
|
Just encountered some exceptions with my original attempt to solve this when I stumbled across this thread.
Here's my current solution (seems pretty robust so far):
==== Pop this in a file ListViewSelectionMover.cs to keep things neat ====
using System.Windows.Forms;
namespace MonkeyWorkshop
{
/// <summary>
/// A static class with methods for moving selected items in a ListView up or down.
///
/// Works for single and multiple selections. Calls do not require any items to
/// be selected. Repaints of the ListView are kept to a minimum.
///
/// Algorithms find a non-selected item (movable) before any selected item
/// before considering a movement (swap). This avoids "leapfrogging" that could
/// occur by running through the selected idicies when they start to bunch
/// at the top or bottom of the list.
///
/// Client code should consider making their ListView.HideSelection = false
/// or loss of focus (e.g. pressing a "Move Up" button) will conceal which
/// items are selected - although the selection will remain.
/// </summary>
public static class ListViewSelectionMover
{
public static void MoveSelectedUp(ListView listView)
{
int i = 0;
bool anyThingMoved = false;
bool movable = false;
int listLength = listView.Items.Count;
while (i < listLength)
{
movable = !(listView.SelectedIndices.Contains(i));
if (movable && (i + 1 < listLength))
{
if (listView.SelectedIndices.Contains(i + 1))
{
if (anyThingMoved == false)
{
anyThingMoved = true;
listView.BeginUpdate();
}
ListViewItem swap = listView.Items[i];
listView.Items.RemoveAt(i);
listView.Items.Insert(i + 1, swap);
}
}
i++;
}
if (anyThingMoved)
{
listView.EndUpdate();
}
return;
}
public static void MoveSelectedDown(ListView listView)
{
int i = listView.Items.Count - 1;
bool anyThingMoved = false;
bool movable = false;
while (i >= 0)
{
movable = !(listView.SelectedIndices.Contains(i));
if (movable && (i - 1 >= 0))
{
if (listView.SelectedIndices.Contains(i - 1))
{
if (anyThingMoved == false)
{
anyThingMoved = true;
listView.BeginUpdate();
}
ListViewItem swap = listView.Items[i];
listView.Items.RemoveAt(i);
listView.Items.Insert(i - 1, swap);
}
}
i--;
}
if (anyThingMoved)
{
listView.EndUpdate();
}
return;
}
} /// Class
}
======
Calling code would therefore need to use:
using MonkeyWorkshop; // Or change the namespace in the above code
Call with:
ListViewSelectionMover.MoveSelectedUp(yourListLiew);
Or clearly...
ListViewSelectionMover.MoveSelectedDown(yourListLiew);
Rich
PS. Thanks for the input
|
|
|
|
|
Hi
I am trying to hide some rows in a DataGridView , in some rows an unhandled exception is fired with the following message .
(( Row associated with the currency manager's position cannot be made invisible.))
handling this exception will cause the row to remain visible .
Any Ideas ?
|
|
|
|
|
You could bind the datagridview to a DataView. Use the filter property on the DataView to hide / show the rows you want based on your conditions.
|
|
|
|
|
Hi
I want to know if it is possible to import from the first sheet of an excel file regardless of the name of the sheet?
I currently import from excel but hard code the sheet name and the file i am importing from now, the sheet name changes every month.
Thank you for your assistance
Nothing lasts but nothing is lost
|
|
|
|
|
Are you using OleDb?
If so then use something like this:
DataTable schemaTable = _oleDbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string firstSheet = schemaTable.Rows[0]["TABLE_NAME"].ToString();
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
thanx that did the trick
Nothing lasts but nothing is lost
|
|
|
|
|
I see you have a solution so you might want to ignore this
Did you know that in Excel each sheet has a 'Code Name' as well as a 'Sheet Name'?
The code name can only be set in the Excel designer (i.e. the VBA window) and stays the same regardless of how the user changes the sheet name.
I used this in VBA code to make sure the code (or macro in Excelese) still worked when users messed about with sheet names.
Not sure how to access it using OleDB but it should be possible.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|