|
I would recommend that you create the file using the stream (read the binary data using the SELECT) and then convert the stream (of binary data) to a file. In simple words, follow what OriginalGriff said above.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
hi
i know how to work with Keystroke and i know how to send any keboard typing
to any open windows to focus place the cursor on local computer.
i work with GlobalKeyboardHook
now, i need to send some data to open windows on focus place using RDP
for any computer that in my net.
how to do it ? my solution dont work
(i work on C# visual-studio 2010 WinForm)
|
|
|
|
|
What are you trying to do on the remote machine?
SendKeys does not work over RDP and GlobalKeyboardHooks are for capturing keystrokes on the machine it's running on, not for sending to another machine.
|
|
|
|
|
hi i had learn c++ and something about the framework Qt but the problem that the Qt is not used for building apps smartphone like C# or JAVA !!
so do u advice me to leave c++ and Qt and start with C# or JAVA ??
please i need your Advice Thank you
|
|
|
|
|
Pick one place and post there, not in QA, C++, and C#.
Otherwise, you duplicate work and annoy people.
You have this posted in QA, so leave it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Don't different people participate in these forums though? There may be folks who only check the C# or say the C++ forums, and others who only check QA. I would think it's alright to cross-post in this situation.
|
|
|
|
|
Indeed, this is true. For a discussion, I would have said that this forum was a far more appropriate choice than QA.
|
|
|
|
|
hello all,
I am creating a list of textbox's dynamically using list and also have added a ok button and created a click_event for the button. But how will i fetch the textbox content that was created dynamically thru the click event of the button. Please see the code below :
public static List<string> InpBox(string title, List<string>prompt, ref string value, int TxtCnt)
{
Form form = new Form();
Button buttonOk = new Button();
Button buttonCancel = new Button();
List<string> inputTexts = new List<string>();
List<textbox> inputTextBoxes = new List<textbox>();
form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
form.AutoSize = true;
form.Padding = new Padding(0, 0, 20, 20);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
form.Text = title;
for (int i = 1; i <= TxtCnt; i++)
{
Label labelInput = new Label();
TextBox textBoxNewInput = new TextBox();
labelInput.Text = prompt[i-1];
labelInput.Location = new Point(0, (i * 30));
labelInput.AutoSize = true;
System.Drawing.SizeF sizeF = new System.Drawing.SizeF();
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new System.Drawing.Bitmap(1, 1));
sizeF = graphics.MeasureString(labelInput.Text, new System.Drawing.Font("Arial,Verdana,Helvetica,sans-serif", 10, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point));
int maxTextWidthinPixel = Convert.ToInt32(sizeF.Width);
textBoxNewInput.Location = new Point(maxTextWidthinPixel - 20, labelInput.Top - 3);
textBoxNewInput.Width = 372;
inputTextBoxes.Add(textBoxNewInput);
form.Controls.Add(labelInput);
form.Controls.Add(textBoxNewInput);
}
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.Location = new Point(form.Width / 2 - buttonOk.Width / 2, inputTextBoxes[inputTextBoxes.Count - 1].Bottom + 20);
buttonCancel.Location = new Point((form.Width / 2 + buttonOk.Width / 2)+10, inputTextBoxes[inputTextBoxes.Count - 1].Bottom + 20);
form.Controls.Add(buttonOk);
form.Controls.Add(buttonCancel);
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonOk.Click += new EventHandler(buttonOk_Click);
form.ClientSize = new Size(396, 135);
DialogResult dialogResult = form.ShowDialog();
return inputTexts;
}
assistance needed. Thanks in advance
Antony,
ansonel@gmail.com
|
|
|
|
|
Since you create a number of textboxes (which is probably a poor idea - have a look at a DataGridView or similar instead, it does most of the work for you) you will have to search for them (or use the inputTextBoxes collection you added them to).
Searching is relatively simple - they are in the form Controls array along with all the others - but I'd just look in your collection! Just move it to a private class level variable and access it in your Click event handler.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi Antony, and welcome to CodeProject !
I think you are using a strategy that is far too complex here.
Why not create one UserControl that has both a Label, and TextBox; then create multiple instances of that UserControl as needed ?
In the UserControl try setting the AutoSize property to 'true on the Label, and its Dock property to 'Left; set the TextBox 'Dock property to 'Fill. That way you can avoid the business your doing now to measure the width of the string.
Within the UserControl, you can expose the TextBox by creating a Public property that references the contents of the TextBox, or exposing the TextBox TextChanged Event.
I like to use "lazy-load" techniques, so I might write something like this in the UserControl:
private string _currentText;
public string CurrentText
{
set
{
_currentText = value;
textBox1.Text = value;
}
get { return textBox1.Text; }
}
As you create the instances of the UserControl, you can, at the same time, create a generic List or Array to store either the TextBox itself or its Text data. Then, when your Button is pressed, you can just iterate over the reference to stored values, or data, and get what you need.
You could use Linq to make an IEnumerable<string>, containing all the strings in all the TextBoxes, or whatever else you need. Assuming I used the string Property shown above, and I kept a List named 'LblTbList<LabelAndTextUserControl> of the Custom User Controls in the Form where they created"
public IEnumerable<string> GetData()
{
return LblTbList.Select(itm => itm.CurrentText);
} That function would return an IEnumerable containing all the strings in all the TextBoxes.
And the code in the context that "consumes" the data (the code your showing using 'ShowDialog) can then iterate over that, or whatever.
private void button2_Click(object sender, EventArgs e)
{
foreach (string txt in YourTestForm.GetData().ToList())
{
Console.WriteLine(txt);
}
} cheers, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
I have this code:
TimelineStart = new DateTime(2015, 08, 11, 10, 00, 00);
TimelineEnd = new DateTime(2015, 08, 14, 20, 00, 00);
TotalHours = (TimelineEnd - TimelineStart).TotalHours;
Day 1 = 10 Hours
Day 2 = 24 Hours
Day 3 = 24 Hours
Day 4 = 20 Hours
TOTAL 78 Hours
The TimeSpan is showing TotalHours = 82.
What's wrong here?
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: Day 1 = 14 Hours
Day 2 = 24 Hours
Day 3 = 24 Hours
Day 4 = 20 Hours
TOTAL 82 Hours
FTFY!
from 10 am to midnight there are 14 hours of day 1 in the total elapsed time!
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
That's wrong.. From 12 am to 10 am is only 10 hours. 10 hours have elapsed.
It's not 10 am until 12 midnight.
If it's not broken, fix it until it is
|
|
|
|
|
You're right in your assertion, but you're wrong in your assumption. The Timespan of day 1 is from 10 AM to Midnight - or 14 hours.
|
|
|
|
|
If I ask you what time it is, and you say "It's 10 am", you're saying "10 hours have past since midnight".
Assuming you're right, and the TimeSpan class represents it as "10 AM to Midnight", then the TimeSpan class is implemented stupidly. Why then is the "Day 4 = 20 Hours", correct? According to what you said, that should be 4 hours.
Time is not "Until midnight". It's "Time elapsed".
That makes no sense at all.
If it's not broken, fix it until it is
|
|
|
|
|
See this diagram:
Day 1 (11-Aug) | Day 2 (12-Aug) | Day 3 (13-Aug) | Day 4 (14-Aug) |
10am - midnight | whole day | whole day | midnight to 8pm |
14 hrs | 24 hrs | 24 hrs | 20 hrs |
Time interval = 14 + 24 + 24 + 20 = 82 hours
/ravi
|
|
|
|
|
Okay, stop thinking that your computer and the rest of us are out to mess with your mind. Let's take this from a none computer perspective and that should make things simpler - imagine you're 7 years old and it's 10 O'Clock on Christmas Eve. How many hours are there until Christmas Day starts? Now, suppose you're told that you can't open your presents until 4PM on Christmas Day. How many hours do you have to wait from the 10 O'Clock time until you can open your presents?
That's all that's going on.
|
|
|
|
|
I understand what you're saying, I just think the implementation is wrong
If it's not broken, fix it until it is
|
|
|
|
|
I don't think the implementation is wrong at all. On the contrary, it seems that your comprehension of the mathematics is what is wrong. If you are interested in computing an elapsed period of time, then that is exactly what is happening.
Take this for example. If you started the clock at 10AM yesterday and stopped it at 10AM today then a total of 24 hours has passed. Yes? The 24 hours is easily broken down in to 10 hours TODAY and 14 hours YESTERDAY. So a time which has elapsed takes the last fraction of the day your started and the first fraction of the day you finished.
|
|
|
|
|
I see you got it now. This was the reply I was writing to your deleted post.
----
How many hours are there between Mon 11:00pm and Tue 2:00am? 3, right?
Even though I said 11:00pm (which is the 23rd hour of the day), there's only one hour left in that day. THAT's the start of the time interval. So you end up with 1 hr left on Mon and 2 hours elapsed on Tue, giving us a total of 3 hours.
----
/ravi
|
|
|
|
|
It's not that I don't get it... I just don't agree with the implementation. TimeSpan is starting from 10 and counting forward, whereas in real life we consider time as time past.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: TimeSpan is starting from 10 and counting forward Yes. But wouldn't you do the same when computing a time interval? For the first day, you'd count the hours left (not elapsed) and for all successive days you'd count the hours elapsed, right? Hence, Mon 10pm to Tue 1am would be a time interval of 3 hours, right?
/ravi
|
|
|
|
|
The TimeSpan isn't counting forward or backward from any specific time.
It is representing (in this case) the elapsed time from one DateTime to another.
It has no concept of forward from "10 am".
If you used an hourglass to count time from 10 am Aug 11 until 8pm Aug 14, you would just be turning the glass over for the 82nd time at the 8pm Aug 14. The TimeSpan is just representing the amount of sand that flowed through neck of the hourglass (with much more precision than counting each grain of sand!!)
It is a signed difference.
If you did the subtraction in the other order it would return -82 hours.
It is just a counter.
[Edit]
var TimelineStart = new DateTime(2015, 08, 11, 10, 00, 00);
var TimelineEnd = new DateTime(2015, 08, 14, 20, 00, 00);
TimeSpan delta = TimelineEnd - TimelineStart;
Debug.WriteLine(TimelineEnd.Ticks);
Debug.WriteLine(TimelineStart.Ticks);
Debug.WriteLine(delta.Ticks);
gives the output:
635751792000000000
635748840000000000
2952000000000
The DateTime items are counters forward from a reference date and time.
The TimeSpan is just representing the difference.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
modified 17-Aug-15 13:20pm.
|
|
|
|
|
Consider a simpler example:
TimelineStart = new DateTime(2015, 08, 11, 10, 00, 00);
TimelineEnd = new DateTime(2015, 08, 11, 11, 00, 00);
TotalHours = (TimelineEnd - TimelineStart).TotalHours;
Subtracting two DateTime instances gives you a TimeSpan representing the difference between the two points on the timeline - ie: how many hours are there between 10:00 and 11:00 on 11th August 2015.
With your approach to the problem, TotalHours would contain 21 . Unless you live next to a black hole, there aren't 21 hours between 10:00 and 11:00 on the same day.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm using VS Community 2013 and I'd like to start a VSTO (Excel) project. However, I don't find any templates listed, local or online.
|
|
|
|
|