Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
This is a hard one. Need to read in plain text from Word, HTML files, and any readable content from drag-n-drop or copy-n-paste. See below for examples:
Drag-n-drop from Word or alike editor:
Copy-n-paste from browsers:
Using the suggested block I'm able to read in most text except the selected values of drop-down, checkbox and radio buttons.
var text = System.Windows.Forms.Clipboard.GetText();
Clipboard.SetText(text);
How to capture the missing selected values/text of drop-down, checkbox and radio button?
var text = System.Windows.Forms.Clipboard.GetText();
Clipboard.SetText(text);
Will turn the rich text on the clipboard into plain text.
On every machine I use I keep a batch file, calld text.bat on my path which does this to the clipboard contents, so I can press Win+R then type text and convert my clipboard contents to plain text.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have an Application build in WPF. It have a Textbox that will always accept only 10 digits and is always ready for Scanning ID Barcode Contains 10 Digits or Entering Number with Keyboard.
Now some Customers are entering just 2 digits and leaving system as it is. Let us say he write 12 in TextBox and left it. When new Customer is coming he is Scanning his Id without noticing that there is something already written in the TextBox. So New Number is coming like this 1224444444 and two numbers are missing that is 34.
How can I clear Textbox before Scanning or Before Writing?
some example code of exactly how you are attempting this would be useful.
A WPF textbox can be cleared by either calling the .Clear method, or simply by setting the "Text" property of the Textbox to string.empty.
With regards to most barcode scanners i've seen and used (usually KB emulation), you can usually set them up to get a prefix and suffix on the data so that you can detect scan input over keyboard input. You can then detect a scan and clear the textbox prior to entering the new information
react at the new scanevent from the barcodescanner and clear the textbox.text with string.empty
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm looking for the best method to import co-ordinates from excel into a C# program. The goal is to retrieve data from the X Pos Column and Y Pos Column and compare them to X position and Y position of the user clicks. What is the best way to get the data from the excel database?
One of the simplest is to use clipboard.
Probably Ctr-C from Excel give few formats of windows clipboard (more or less powerful)
Simple way is to use basic (main, natural) clipboard format, cells are delimited with tabulator \t and lines with \n
Such multiline strong You can split or parse in other way, up to You.
Read MSDN about System.Windows.Forms.Clipboard.GetText(....)
If the goal is to import data from an XLS(X) document, you can use http://spreadsheetlight.com/
(It does not require Office installed on the workstation)
You can open the document, select a sheet and read data row by row for instance.
You should store the coordinates in a proper data structure and compare them with the cursor coordinates when mouse events are triggered.
Quick sample to get cell value ;
using(SLDocument document = new SLDocument("TheFile.xlsx", "TheSheet"))
{
string cellContent = document .GetCellValueAsString("A1");
document.CloseWithoutSaving();
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
when I put a breakpoints on my textbox it shows textbox.length = "" even if there are characters in the textbox
There is no Length property present in TextBox Class.
Probably you mean to Check the Length on Textbox Text property which is of string type.
textbox.Text.Length
More info about the code would be nice. Is your Textbox really enabled? No transparent layer in front of it? You used the mySQL-Tag. Does that mean you use some kind of binding in textbox? Possibly you can't change the content of your textbox, because the database-binding / connection is read-only?
Is there really some textbox.length property?? Are you sure you are referring to the right property? Try this:
Convert.ToString(textBox1.TextLength)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make like a container application where you can drag and drop files of any kind on the form and afterwards to be able to open it from there. I found some solutions where you can drag and drop files to a list view and you get it's path.. but is not how I want.. I want to have on my form in a panel or what ever is better like a shortcut of the file, an image or something to be able to see the file icon like is in explorer.
Have someone ever done something like this or point me to the right direction?
Set "Allow drop" property to "true" on your control and make use of Control.DragDrop event - it's exist on all controls, and it's invoked after drag'n'drop anything on anything(if "Allow drop" is true of course).
It this event-handler you can add new item to this or another control(ListView fits nicely to your needs), and for example to some "Dictionary" where you will store "Item and filename mapping".
Also you need to make handler for item click'ing - for ListView there a ItemActivate event. Inside this handler you can click execute default shell-action for this file by using Process.Start
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 14 years ago.
Improve this question
I have a Winform application built with C# and .Net 2.0. I have a textbox set with the MultiLine property.
The problem is when someone writes text with multiple lines (press few enters), presses the save button, and then closes and loads the form again, all the new lines disappear (the text is there at least).
For example, if the textbox had this in it:
Line1
Line3
It will look like this after I save and load:
Line1 Line3
Any idea why?
Update
The database is PostGres and when I use PGAdmin I can see all the line AND the "enters". So the persistence seem to have save all the line... the problem seem to be when I put back the string in the Textbox.
If I recall correctly, the textbox is really a string array.
I think you can do this:
textBox1.Lines = foo.Split(new String[] {"\n"},StringSplitOptions.RemoveEmptyEntries);
Edit again: If you want to keep the blank lines, the change to StringSplitOptions.None
In Windows forms all carriage returns are preserved in a multiline text box, so the problem likely lies in the way data is retrieved from your database. I've never used PostGres, but I'm guessing that the way you're retrieving the text from the db is replacing all whitespace with single spaces.