15,894,740 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Smeezy (Top 34 by date)
Smeezy
3-Feb-20 10:01am
View
Understood. Again, thank you!
Smeezy
3-Feb-20 9:56am
View
I really appreciate your help Richard! This was enlightening if for no other other reason than to reinforce the knowledge that I have a long way to go! I do need to ask though, why was this not as simple as it was to do with the backcolor?
Smeezy
3-Feb-20 9:54am
View
OK. I just figured that out. I forgot to add the save dialog back in!
Smeezy
3-Feb-20 9:49am
View
Not sure I'll ever get beyond where I'm at with coding! This is kind of working now. Regardless of what color I choose, when I reopen the program, the forecolor of all labels is red. I don't see where that is coming from.
//Allows user to set Label ForeColor and saves as a default color.
private void btnFcolor_Click(object sender, EventArgs e)
{
using (var dlg = new ColorDialog())
{
if (dlg.ShowDialog() == DialogResult.OK)
{
SetLabelColor(Controls.Cast<control>(), dlg.Color);
}
}
private void SetLabelColor(IEnumerable<control> controls, Color color)
{
foreach (Label label in controls.OfType())
{
label.ForeColor = color;
}
foreach (Control control in controls.Where(c => c.HasChildren))
{
SetLabelColor(control.Controls.Cast<control>(), color);
}
}
private void Form1_Load(object sender, EventArgs e)
{
SetLabelColor(Controls.Cast<control>(), Properties.Settings.Default.FormForeColor);
}
Smeezy
3-Feb-20 9:36am
View
I did not set that. Is that as simple as putting "SetLabelColor;" in the Form1_Load?
Smeezy
3-Feb-20 9:22am
View
I removed the binding, and it did stop affecting the button color, but it still will not save the change.
Smeezy
3-Feb-20 8:58am
View
Yes. I dragged button objects from "common controls". What I think the problem is though is the "FormForeColor".
After selecting the form, I then created a binding object called
FormForeColor". In application settings in properties, I then bound that to the forms "ForeColor". I'm sure that's affecting all objects on the form, however, just using "Forecolor" alone in the btnColor control (below), gives me another underline error.
private void btnFcolor_Click(object sender, EventArgs e)
{
using (var dlg = new ColorDialog())
{
if (dlg.ShowDialog() == DialogResult.OK)
{
SetLabelColor(Controls.Cast<control>(), dlg.Color);
Properties.Settings.Default.FormForeColor = dlg.Color;
Properties.Settings.Default.Save();
}
}
Smeezy
3-Feb-20 8:16am
View
Hi Richard, I updated as you instructed, but still no success. As before, the label ForeColor, and button Forecolor (which I don't want) are both changing, but only the button forecolor saves. So the button forecolor is changing and saving as I expect, it's just that it should not be happening on the button! Why is it changing though? I don't see anything coded to make it change. This time I included the forms back color functions below that are working a they should just as a reference.
//Reverts FormBackColor to default installation color. (this works as expected)
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
this.BackColor = Properties.Settings.Default.FormBackColor = System.Drawing.Color.DarkSlateGray;
Properties.Settings.Default.Save();
}
//Allows user to set FormBackColor and saves as a default color. (this works as expected)
private void btnColor_Click(object sender, EventArgs e)
{
using (var cd = new ColorDialog())
{
if (cd.ShowDialog() == DialogResult.OK)
{
this.BackColor = Properties.Settings.Default.FormBackColor = cd.Color;
Properties.Settings.Default.Save();
}
}
}
//Creates control for changing label forecolors. (this also changes the button forecolor though).
private void SetLabelColor(IEnumerable<control> controls, Color color)
{
foreach (Label label in controls.OfType())
{
label.ForeColor = color;
}
foreach (Control control in controls.Where(c => c.HasChildren))
{
SetLabelColor(control.Controls.Cast<control>(), color);
}
}
//Allows user to set Label ForeColor and saves as a default color. (this will change the label and button forecolors, but only saves the button forecolor)
private void btnFcolor_Click(object sender, EventArgs e)
{
using (var dlg = new ColorDialog())
{
if (dlg.ShowDialog() == DialogResult.OK)
{
SetLabelColor(Controls.Cast<control>(), dlg.Color);
Properties.Settings.Default.FormForeColor = dlg.Color;
Properties.Settings.Default.Save();
}
}
}
}
}
Smeezy
31-Jan-20 15:12pm
View
So I keep getting "Controls" red underlined that says: cannot convert from 'System.Windows.Forms.Control.ControlCollection' to 'System.Windows.Forms.Form.ControlCollection' within the button code.
Then within the SetLabelColor method 'Controls' and 'Would' both give me another red underline with the error: 'Form.ControlCollection' does not contain a definition for 'Controls' and no accessible extension method 'Controls' accepting a first argument of type 'Form.ControlCollection' could be found (are you missing a using directive or an assembly reference?)
Smeezy
31-Jan-20 13:53pm
View
I'll give that a shot. I have to move on to something else right now. I'll report when I go back to that. Thank you.
Smeezy
31-Jan-20 13:48pm
View
I have that in there already.
Smeezy
31-Jan-20 13:40pm
View
Thank you Richard. I tried your code, but get "squiggly line" errors. Specifically the words "Where" and "Controls" (with the capital C). I don't quite understand everything you said here. Is there somewhere I can read about this? Do I need to add a "using" or reference or something?
Smeezy
31-Jan-20 12:46pm
View
So this is what I originally had. The problem at this point is that anything I replace "FormBackColor" with gives me an underline error. Using FormbackColor won't work either, because it then affects only the formbackcolor, and not the label forecolor.
private void btnFcolor_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
if (cd.ShowDialog() == DialogResult.OK)
foreach (Control l in Controls)
{
if (l.GetType() == typeof(System.Windows.Forms.Label))
{
l.ForeColor = cd.Color;
}
l.ForeColor = Properties.Settings.Default.FormBackColor = cd.Color;
Properties.Settings.Default.Save();
}
}
Smeezy
31-Jan-20 12:18pm
View
The same line of code I used for the FormBackColor (adjusted for FormForeColor of course) just gives me errors when I try it with the forecolor. I thought it might be due to the "foreach" iterating through the labels. On a scale of 1-10 with coding, I'm at a solid 0.75, so beyond that, I cannot give you a better answer. It just gave me underline errors.
Smeezy
31-Jan-20 12:14pm
View
I used "FormBackColor" to bind the changes to the form color, but when I tried it with "FormForeColor", all it did was change the color of one Button Font. I then put everything into a panel but it then only changed the color of one label.
Smeezy
31-Jan-20 12:09pm
View
I had it there, but it doesn't work. That's why I'm here.
Smeezy
7-Jan-20 7:39am
View
Thank you Pete. I'll research that route.
Smeezy
18-Dec-19 13:37pm
View
I have that already. The composite function creates a bitmap that gets pasted into Word. I want to stick to using actual text.
I just found out today how to make zero space between lines in Word. In light of that, I created fonts, that when stacked per line, create the composite symbol. It seems to be what I was trying to do!
But thank you anyway!
Smeezy
8-Jul-19 11:25am
View
Some of these revs don't change for 30 years, some 5 years. Some of these revs are not seen by one person for two years while another may use some of them every day.
I perform the updates. I would not know if a rev changed unless I needed to use the specification that changed. Someone else may be aware of the change.
By prompting them to verify revs every year, the odds of anything getting missed are nil. Whereas if it's done how you're suggesting, someone would open the specs just assuming they're up to date, in fact there could be one sitting there that I'm not aware of, and would have had no way to know unless I was using it.
So no matter who's using what rev on what specification, I'll be made aware that a change is necessary. This is why each person is responsible to verify their own rev levels.
Smeezy
8-Jul-19 10:42am
View
MadMyche, simply, then I would be required to monitor rev levels. What if I'm gone, or leave this company and the revs expire? What I'm doing is making each person responsible to verify the information they're using is correct every year. We're engineers. We already have to do it. The difference is, currently we can throw away the old rev and print the new one. What I'm building here just makes our jobs more efficient.
Smeezy
8-Jul-19 8:52am
View
There are several people who have it installed. When they open it, it automatically checks for updates I've made on the server.
Why is the date they last opened it relevant? The way I am thinking of this working is that it's just functioning against a calendar. Doesn't it know that from the computer?
I'm not trying to be difficult. I just really don't understand the process you’re explaining and it’s likely because you don’t have all the information. Some of the next paragraph just occurred to me after reading your response.
I just need it to be specific to a computer, and not a person. So if the warning pops up, they (whoever the computer belongs to) have 5 days to check revisions. On day 6 they enter the passcode to signify they have confirmed levels are current. The other option is that they missed the warning. Whenever they open it again, it’s locked, and they have to verify revisions then. Either way, if they're using it with an out of date revision then they (whoever the computer belongs to) approved it. No one else could have.
Still, my sticking point is having the software function without asking for the passcode every time it’s opened after they enter it the first time. Until, that is, the warning period the following year.
Smeezy
21-Jun-19 7:06am
View
I spent the last month trying to figure this out (that's probably the real cost of software right there)! Thank you so much Bill!
Smeezy
20-Jun-19 8:46am
View
I am quite certain that any novice asking questions on this forum knows some other subject to a depth that someone who knows coding could not understand without stumbling and asking questions. Why subject them to ridicule for asking questions that each and every one of you have probably asked at some point in your journey of learning? Do you believe you're superior because you learned it first? This phenomenon is present on every single coding forum. It's pathetic really.
Smeezy
31-May-19 12:26pm
View
Happy to report that this is all working correctly now! I appreciate your help.
int pos = txtFCF.SelectionStart;
string str = lblP.Text;
txtFCF.Text = txtFCF.Text.Insert(pos, str);
txtFCF.SelectionStart = pos + str.Length;
I did need to keep this in a textchanged event on the textbox. Without it, the caret kept going to the start position.
txtFCF.SelectionStart = txtFCF.Text.Length;
txtFCF.SelectionLength = 0;
Smeezy
29-May-19 8:14am
View
I surely appreciate your help OriginalGriff, but if I knew what code was giving me the problem, and why, I wouldn't need to ask for help. Originally my question was simply to ask about the multiline textbox. I’m not familiar with it at all. I didn’t know if this is just how it works. I’m not a professional either. I know just enough to get by, and this is a personal use item to make my real job more efficient. This is basically all of my code. There are about 40 similar statements like the first two. I only posted two to condense it. I’m going to try what you laid out for me. In the meantime, can you tell me where my problem is in this code? Even if I get your code to work as I need, I’d like to know what I did wrong in mine so I can learn something here. I don’t expect it to be done for me, that’s not going to help me learn. The only things missing from this are the close button, and a newline button, both of which work fine. I thought they would just clutter things. So my problem has to be somewhere in the code below.
private void lblCbore_MouseClick(object sender, MouseEventArgs e)
{
txtFCF.Text = txtFCF.Text.Insert(txtFCF.SelectionStart, lblCbore.Text);
}
private void lblDiameter_MouseClick(object sender, MouseEventArgs e)
{
txtFCF.Text += lblDiameter.Text;
}
private void btnCopy_Click(object sender, EventArgs e)
{
if(txtFCF.Text == "")
{
//this is just to prevent an error. No message required.
}
else
Clipboard.SetText(txtFCF.Text);
txtFCF.Text = "";
txtFCF.Focus();
}
private void btnBackspace_Click(object sender, EventArgs e)
{
if(txtFCF.Text == "")
{
//this is just to prevent an error. No message required.
}
else
txtFCF.Text = txtFCF.Text.Remove(txtFCF.Text.Length - 1, 1);
}
// An explanation of the below code. Prior to finding this solution through a search, the caret would revert to the beginning of the first line every time I entered text. It would put the entered text at the end, but the caret would remain at the beginning. Still though, if I deleted any letter, it would add the next letter to the end of the last line (same problem I’m having now). All the code below did was prevent the caret from staying at the beginning of the first line.
private void txtFCF_TextChanged(object sender, EventArgs e)
{
txtFCF.SelectionStart = txtFCF.Text.Length;
txtFCF.SelectionLength = 0;
}
Smeezy
28-May-19 14:26pm
View
The "code" has nothing to do with the deleting, and it works as it should. I'm speaking about physically deleting a character with the keyboard. Imagine for a moment you're using it yourself, and you find you have a typo on line 18 of 125 lines. You could delete everything in the box and start over, or you could either backspace, or hit delete to remove the offending character. If you backspace, or delete, the caret automatically jumps to the end of line 125 when it should stay right where it is so you can enter the correct character. Who wants to scroll through 125 lines of text to find where they delete an "E"?
So again, at this point there is nothing wrong with the code. It just has an additional quirk that I'm hoping can be eliminated. I hope this was a sufficient explanation.
Smeezy
28-May-19 12:39pm
View
Sorry, I might have said it in a confusing way. It's not deleting anything. When I delete, for example the letter "A" from line two, the caret automatically jumps to the end of the last line, whether that's line 3 or 4. Can that be prevented? Other than that, it's working as it should.
Smeezy
28-May-19 12:25pm
View
I have no doubt that you know what you're talking about, and are obviously light years ahead of me on this, but as you can see below, I did put your code in, and it's working exactly the same as the single line I commented out above each of your code sets. When I delete an item, the caret goes to the end of the last line.
private void lblLeft_MouseClick(object sender, MouseEventArgs e)
{
//txtFCF.Text = txtFCF.Text.Insert(txtFCF.SelectionStart, lblLeft.Text);
int pos = txtFCF.SelectionStart;
string str = lblLeft.Text;
txtFCF.Text = txtFCF.Text.Insert(pos, str);
txtFCF.SelectionStart = pos + str.Length;
}
private void lblMid_MouseClick(object sender, MouseEventArgs e)
{
//txtFCF.Text = txtFCF.Text.Insert(txtFCF.SelectionStart, lblMid.Text);
int pos = txtFCF.SelectionStart;
string str = lblMid.Text;
txtFCF.Text = txtFCF.Text.Insert(pos, str);
txtFCF.SelectionStart = pos + str.Length;
}
private void lblRight_MouseClick(object sender, MouseEventArgs e)
{
//txtFCF.Text = txtFCF.Text.Insert(txtFCF.SelectionStart, lblRight.Text);
int pos = txtFCF.SelectionStart;
string str = lblRight.Text;
txtFCF.Text = txtFCF.Text.Insert(pos, str);
txtFCF.SelectionStart = pos + str.Length;
}
Smeezy
28-May-19 12:05pm
View
I did try both the code you provided, and also this,
private void lblY_MouseClick(object sender, MouseEventArgs e)
{
txtFCF.Text = txtFCF.Text.Insert(txtFCF.SelectionStart, lblY.Text);
};
They both worked the same way. The caret however reverts to the end of the last line after I delete something, rather than staying where the item was deleted. Is there a way to prevent that?
Smeezy
28-May-19 11:32am
View
OK, I think I just figured it out. I need to eliminate the += and just use =. Is that correct?
Smeezy
28-May-19 11:26am
View
I just tried this, but it's not working
txtFCF.Text += txtFCF.Text.Insert(txtFCF.SelectionStart, lblFinish.Text);
Each item I click concatenates to form what's referred to as a "feature control frame".
It works as needed if I use just one line, but would be more useful if I could get this working.
Smeezy
28-May-19 11:14am
View
Programmatically. I was editing my comment to show the code as you replied. I realized why it was happening right after I submitted my question. I'm still not sure how to correct it though. I need to tell it to insert my item wherever the caret is.
Smeezy
23-May-19 13:00pm
View
Thanks to all who replied to this. What I did was put each letter, symbol and number into its own label. I then added a click event to each one, adding its contents to a textbox where they each concatenate to the previous one. It works perfectly.
My next issue involves a multiline textbox. If I have three lines for example, how can I add text to lines other than the last one? Each time I add something, no matter where the caret is, it adds it to the last line in the box.
This is the same program my original question was about. It works as I need it to with one line, but would serve a better purpose with a multiline box. Any ideas?
Smeezy
5-Apr-19 10:15am
View
I appreciate your comment, and the work you've done, but I have a question. One would have to assume that the application in question is going to be used by more than one person at a time, but your instructions state that it should not be used by more than one user at a time. This would work fine if I wanted to make changes on my own program, and then update my own installation, but that seems kind of inefficient, or am I seeing this wrong? I'm not a pro, so I could be.
Show More