Standard multiline textbox, would like every line bulleted automatically - winforms

I have a multi-line textbox in which I'd like every newline to also include a bullet character and a space before the next line of characters. Chr(149) AKA hex 95 looks good with the font I'm using. Further, the first line should have a bullet which appears automatically upon adding any text.
Basically, I want a textbox that's nothing but a list of bulleted items. I don't want to give the user the ability to italicize or anything else, so no Richtextbox.
I can handle this upon loading data into the textbox with a simple replace, but I'd like it to happen on-the-fly, while typing or while pasting from the clipboard, with bullets added automatically after every [Enter] keystroke or upon pasting text with linebreaks, and without the text cursor jumping around inappropriately.
Since I often see replies with "Why would you do this?" I'll explain: The user will use this textbox to enter a few brief points about a particular customer, such as "Gate code #1234" or "Customer doesn't like garlic." or "Make sure to mention her dog." It could be almost anything, and occasionally it's a few sentences, but each "point" (even if it's a paragraph) should stand out as visually distinct. I don't want a blank line eating up screenspace to separate paragraphs, but bullets will make each "entry" distinctively obvious as its own point. This is especially valuable when a given point ends near the right side of the textbox, so the next point doesn't appear to be part of the preceding point.
My code below "kinda starts to work" and it could be improved by placing the text cursor back where it was while typing (using Selstart) instead of jumping to the beginning, but I haven't gotten that far because it also creates issues when deleting the bullet, and when pasting or cutting. It could also be improved by adding a bullet before the first line. Those things are easy.
I'd like a simple "linebreak = linebreak and bullet" algorithm that works on the fly with cutting, pasting, typing, deleting and I suspect it already exists somewhere but I haven't found such code.
Or, if there's a simple way to give the textbox a "custom font" in which the linebreaks actually include a visible glyph that looks like a big dot, that would work too.
Thanks for reading my question.
Private Sub tbOfficeNotes_TextChanged(sender As Object, e As EventArgs) Handles tbOfficeNotes.TextChanged
Static MakingChanges As Boolean = False
If MakingChanges Then Exit Sub
Dim s As String = Replace(Replace(tbOfficeNotes.Text, vbCrLf, vbLf), vbCr, vbLf)
'The line above replaces any form of newline with LF only.
s = Replace(s, Chr(149) & " ", "")
MakingChanges = True
'Avoids a recursive loop as the next line would force this event to trigger from itself.
tbOfficeNotes.Text = Replace(s, vbLf, vbCrLf & Chr(149) & " ")
MakingChanges = False
End Sub

Related

If a line of text is separated into multiple text leaves in the accessibility tree, is it still accessible well?

Below is a picture of my current accessibility tree. You can see that the 4 text leaves in it are separated, but it still forms only one line of content. Is this still accessible well ("well" meaning screen readers can detect that they form one complete sentence), or should all of the text leaves be combined into one leaf?
If they should be combined, how can you concatenate variables into the text in React, while keeping it as one single leaf? This is my current code: <p>{cloudiness}% ({cloudinessDescription})</p>
How they are read aloud depends on the screen reader being used. VoiceOver reads it as one phrase, but that doesn't mean others will. Having it split up wouldn't be a nice experience, but it doesn't mean it's not accessible.
If you really want to make sure it's read as one phrase but don't like the noise of the template literal inside the JSX (I agree), why not define the string somewhere else until you are able to test on multiple screen readers?
const cloudinessSummary = `${cloudiness}% (${cloudinessDescription})`;
return <p>{cloudinessSummary}</p>;

Reportbuilder showing the same like WPF

So I'm programming and I want to show my first name and last name but i want my last name on a new line. Of course I use the function \n right after my first name. In WPF it shows it like how it should be shown:
first name
last name
If I now want to show this through a report with SSRS this will not work cause my report will show first name \n last name. Is there anyway that report builder will understand this function and give me the same representation like in WPF?
I don't think it will ever understand "\n". Instead of "\n", use "vbcrlf" - that sticks in a carriage return and drops the text to a new line.
You can just encase the field with your text with the below:
=Replace(Fields!<<fieldname>>.Value, "\n", vbcrlf)
Make sure the text is not set to interpret tags as HTML and you'll be fine.

Disable all Emacs c-mode reformatting, insertion/refusal, cursor jumps

I want to keep all syntax highlighting, autocomplete, commands etc. of Emacs c-mode (and I'll add in company-mode or similar shortly) but I want to disable everything in c-mode which:
Reformats other than if I C-<command> or M-<command> ask it to.
Moves my cursor around the source, even momentarily, unless I asked for it. For example, closing parens/braces highlighting the matching one.
Ever i) inserts anything I didn't type (other than 1 Tab = 4 spaces) or ii) refuses to insert something I did type because formatting.
Reformats, repaginates, realigns or otherwise edits the source for any reason, including on paste, on save, or because the moon is gibbous.
I've already set (setq-default c-basic-offset 4) and (setq-default indent-tabs-mode nil).
I have tried:
C-x C-l a.k.a. c-toggle-electric-state a.k.a. (setq-default c-electric-flag nil) which fixes some of 4, but Tab still reformats code when it feels inclined, and I'm guessing isn't alone; and doesn't fix 2 or 3.
c-auto-align-backslashes which fixes one above case only.
(setq c-syntactic-indentation nil) which partially fixes 4, but breaks 1 and 3 (for instance, Tab doesn't insert at the cursor), and doesn't fix 2.
text-mode which obviously removes all the c-mode features I want to keep.
Various searches and dives into https://www.gnu.org/software/emacs/manual/html_mono/ccmode.html, which carefully documents 2^1024 settings but doesn't exhibit an "all formatting off" switch that I can find.
Scanning https://sourceforge.net/p/cc-mode/cc-mode/ci/default/tree/ for obvious flags to disable (*blork*?)
I've been at this for hours, so any help gratefully received.
Update: More thrashing around: installing emacs source code (apt-get install emacs24-el) and using C-h k <key combo> to find the function called when a key is pressed. M-x find-function to browse that source to work out what it's actually doing and look for hooks. (setq-default indent-tabs-mode nil) to stick with spaces, not tabs. (setq-default blink-matching-paren nil) to prevent cursor jump on closing parens/braces. I still can't disable formatting, or achieve 1, 2, 3 and 4, but I'm getting better at whack-a-mole.
First observation: this is a difficult sort of question to answer, because "disable everything that does ...." is a bit unspecific. However...
Item 2. (Moving point momentarily to the matching open paren when you type a close paren) is easy: (setq blink-matching-paren nil). This is in the Emacs manual on page "Matching Parentheses". (Whoops! You've already found that one).
You don't like the action of the tab key; what do you want it to do? It's bound to c-indent-command, which indents the current line inwards or outwards to the "correct" position. I'm guessing you want simply to insert spaces to bring point to the next 4*nth position. How about tab-to-tab-stop? Try (define-key c-mode-base-map "\t" 'tab-to-tab-stop). Note that defining it in the default key map would not work, since the major mode key map takes priority over it.
Having done C-c C-l to disable the automatic indentation on typing, e.g., a ;, does typing a ; still do anything to offend? If so, you could disable its "special" features entirely with (define-key c-mode-base-map ";" 'self-insert-command)
Again, a list of specific things you don't like, even a long list, is a lot easier to deal with than "everything which inserts anything I didn't type". The maintainer of the mode just doesn't mentally classify things that way.
Anyhow, I hope you manage to get things sorted out.

How to create an array with textboxes in Visual Basic 6.0

I am working on a very old visual basic project. I have to rewrite the load and save function of the project. Therefore I wanted to create an array of controls which have all relevant textboxes and checkboxes included. I want to iterate through that array to be able to save the data into a textfile or load from it.
I have looked on the internet of how you can define those arrays, but it doesn't seem to work for me. Maybe I am doing something wrong, cause I am not an expert in Visual Basic.
I have tried to make it work this way:
Dim tbList As TextBox = { Form1.Text1, Form1.Text3, _
Form1.Text10, Form1.Text11, Form1.Text12, Form1.Text13, _
Form2.Text1, Form2.Text3, Form2.Text4, Form2.Text5, _
Form2.Text10, Form2.Text11, Form2.Text12, Form2.Text13, _
Form3.Text1, Form3.Text3, Form3.Text4, Form3.Text5, _
Form3.Text10, Form3.Text11, Form3.Text12, Form3.Text13, _
Form3.Text17, Form3.Text18, Form3.Text19, Form3.Text20, _
Form4.Text1, _
Form5.Text1, Form5.Text2, Form5.Text3, _
Form6.Text2, _
Form7.Text2}
Or with a list:
Dim tbList As New List(Of Controls)
The thing is Visual Basic always tells me there are some kind of compiling issues. There is no real explantation for this issue in VB, so I am asking here.
Your code isn't compiling because it is vb.net code. It should go without saying (but I'll say it anyway) that vb6 and vb.net are not the same thing.
If you want to use an array, you will have to dimension the array with a number that is one less than your number of textboxes (if I counted correctly there are 32 in your example):
'// array is zero based so 0 to 31 = 32 items
Dim tbList(31) As TextBox
tbList(0) = Form1.Text1
tbList(1) = Form1.Text3
'//...I'll leave the rest as an exercise for the programmer
tbList(31) = Form7.Text2
Dim i As Integer
Dim tb As TextBox
'// To loop and work with each textbox
For i = 0 To UBound(tbList)
Set tb = tbList(i)
'// do something with tb
Next
An easier way to do it, however, is to work with a collection:
Dim tbList As New Collection
tbList.Add Form1.Text1
tbList.Add Form1.Text3
'//...I'll leave the rest as an exercise for the programmer
tbList.Add Form7.Text2
Dim tb As TextBox
'// To loop and work with each textbox
For Each tb In tbList
'// do something with tb
Next
Yes, you can use a collection if you want to go to the trouble. But an even easier way to work with it is to use VB6's (now obsolete) control array implementation. Most of us were disappointed when we found it was no longer available in .Net!
All you have to do to get control arrays in VB6 is create a bunch of controls with the same name. (They do have to be the same type of control; you can't make arrays of, say, text boxes and combo boxes.) Start with one text box, name it what you want, and copy it. You will be asked if you want to create a control array. Say yes, copy as many as you want. You will notice that the Index property is no longer blank, starting with 0 and incrementing from there. You will also notice that all of the event handlers have an "Index As Integer" argument to them. This way, you can use the same event handler for all of them, evaluating the Index argument to find out which member of your array is firing the event.
Here is the old doc for it. Microsoft makes it hard to find. :)

Show progress bar when sending pages to the printer (WPF)

I am creating printouts in WPF using flow documents. These printouts are set in separate window where DocumentViewer is placed.
When user clicks print I would like to show a progress bar that informs about current page that is sending to the printer. How can I do this?
I'm not sure exactly where your print code is, or where you want the progress bar, but I did something similar to this recently. This will be in VB.net.
First of all, create a new progressbar in the same class as the code you use to send the page to the printer. Then, we're going to take advantage of the "top-down" order in a block of code to change the progress bar.
The progress bar's value should be set to "0" be default. Now, in the code for sending the page to the printer, you're going to increase the progressbar's value (such as with the code "MyProgressBar.Value = MyProgressBar.Value + 1"). Put this code in between each line of the code you want to show progress for.
I would change the "+ 1" part of the code, however, to another value, so your progress bar progresses equally after each step. If you have three lines of code, then use "+ 33" (100\3), four lines use "+ 25", etc.
Finally, at the end of the code, set "MyProgressBar.Value = 100"
This only works, however, if you have access to a code longer than one line. For one line of code, I'm not sure how this works, unless you can get to the block of code that line points to.
If you have to use code from another class, you may need to do something like...
Dim MyWindowWhereProgressIs As New MyWindowWhereProgressIs
And then, each time you need to change the value, try...
MyWindowWhereProgressIs.MyProgressBar.Value = MyWindowWhereProgressIs.MyProgressBar.Value + 1
I'm not entirely sure whether or not those last two lines of code will work, as I'm away from Visual Studio right now, but it is worth a shot.

Resources