|
I was trying to determine on how to get this to work.
When clicking on either up or down, its already set to 0.1 increment/decrement value.
However, when shift key is pressed and clicking either up or down, the increment would change to 1.0 increment/decrement.
I've done the coding but it delayed the increment change. When I shift-click, I had to click twice on the up button for the step value to change.
What's the effective way to get the step value to change upon the shift-click is detected?
|
|
|
|
|
Create your own class, derived from NumericUpDown. Override the UpButton and DownButton methods:
public class MyUpDown : NumericUpDown
{
public override void UpButton()
{
decimal save = Increment;
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
Increment *= 10;
}
base.UpButton();
Increment = save;
}
public override void DownButton()
{
decimal save = Increment;
if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
{
Increment *= 10;
}
base.DownButton();
Increment = save;
}
}
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
In the C# Visual Studio 2010 project I am working on, I cannot edit or add a path to a referece file. I have inherited a project at work. When I open the project and go to the references scetion in the Visual Studio 2010 IDE there are some little yellow warning signs showing that there is something amiss with the reference listed there.
But when I click on the item and look at the missing path, I find that the name "Path" is in grey suggesting that I cannot edit it and, sure enough, I cannot add the path name to the adjoining field. What causes this? I have the solution file and the project file checked out in edit mode.
When I open the project file, the error list also gives the warnings for each missing reference:
"The reference component '(the file name)' cound not be found"
Well, I know where they are but editing the path to point there is the problem.
|
|
|
|
|
Try deleting them from the project and then adding them in again using the actual location.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
That probably would have worked.
A Project file is an XML file.
We found that the project file had a hand-coded reference that was wrong.
|
|
|
|
|
The project file had a hand-coded reference that was wrong.
|
|
|
|
|
Hi,
Can I use a user control as a base class to write some
user control variations. I have a user control with a panel. I would like to create another user control based on the first, but with some controls in that panel. How can I do this using the designer ?
tia
|
|
|
|
|
You certainly can:
class ExtendedUserControl : MyUserControl {
}
I've no idea if you can create one in the designer but you can certainly design one once it exists (a previous project of mine was full of these).
Take note though that if MyUserControl is abstract, VS's designer throws a fit and refuses to design it (not sure if this is also true in e.g. SharpDevelop). That can be very annoying.
|
|
|
|
|
Hi,
Now I do :
public partial class PricePanelBase : UserControl
{
public PricePanelBase()
{
InitializeComponent();
InstallControls();
}
protected virtual void GetControls(ControlCollection Ctrls)
{
}
private int InstallControls()
{
ControlCollection Ctrls = new ControlCollection(CPanel);
GetControls(Ctrls);
foreach (Control Ctrl in Ctrls)
CPanel.Controls.Add(Ctrl);
return Ctrls.Count;
} ...
public partial class PricePanel : PricePanelBase
{
public PricePanel()
{
InitializeComponent();
}
protected override void GetControls(ControlCollection Ctrls)
{
DataGridView GrdVw = new DataGridView();
GrdVw.Name = "dataGridView1";
GrdVw.Location = new Point(3, 35);
GrdVw.Size = new Size(438, 146);
Ctrls.Add(GrdVw);
}...
When I drag the PricePanel control in a form I get an ArgumentException:
'Child' is not a child control of this parent.
and the control doesn't get drawn.
|
|
|
|
|
Inheritance is a great thing but I strongly recommend against inheriting from custom user controls in winforms. It gets very ugly, very quickly.
"You get that on the big jobs."
|
|
|
|
|
Hi
Good morning. My query is,i have Some application. In that application i have some one sub directory. In that directory i have 3 jpg files. i want to read those files from directoiry and i need to store the Image file name, Image bytes into data base. Once completion of reading files from the directory i need to delete those files.Can any one sunggest me how to approach that.
|
|
|
|
|
I can tell you that this is a install-time problem, not run-time.
The database should be populated with this information when the application is installed. If you're going to delete the image files, why are you even adding them to the app?? Just populate the database with the data at install-time.
Why? Because a normal user cannot modify anything under Program Files. When someone launches an app, the app inherits the security token of the user (the app runs AS the user who launched it). Normal users do not have Write or Modify permissions to anything under Program Files.
|
|
|
|
|
Just write code for each of the steps you outlined. Storing byte arrays in a database is the topic of many articles. Come back here if you have a specific question.
|
|
|
|
|
Hello everybody, I have an issue about GDI objects.
Whenever the form close and then reload the no of GDI objects is increasing continously in task manager. Although objects of form is disposed on every form closing time but it is increasing. How I can dispose all those objects which are not disposing.
|
|
|
|
|
You have to call Dispose on any GID object THAT YOU CREATE that offers a Dispose method.
If you've forgotten to Dipose something, you can't go back later and just do a global Dispose. You have to fix your code and Dispose of the object properly when you're done with them, because once the object variable falls out fo scope, it's too late to call Dispose on it.
|
|
|
|
|
You should dispose explicitly of any objects that offer a Dispose() method, in a WinForms GUI environment that would include Fonts, Pens, Brushes, etc. And also any Graphics, which you normally don't need to create at all as the Paint handler provides one for free (you should NOT dispose of that one, you did not cause its creation!).
I typically do not create new Fonts/Pens/Brushes in my Paint handler, I create them once and keep them around as static class members (gives better performance), and I do not dispose of them at all. Them being static means extra instances of the Form don't add to the GDI count.
|
|
|
|
|
Hi All,
Yesterday I asked the about the best way to handle strings in C# and got myself into and out of a hole. Today I have the result nicely in a rich Text Box with no spaces/awkward characters now I would like to search the List of data as I'm guessing this is more efficient than going through the text property of the rtb.
<pre lang="c#">
for (int i = 0; i <= NAME.Count - 1; i++)
{
richTextBox2.Text += NAME[i] + "\n";
} //loads the rtb!
bool exists = NAME.Exists(element => element == element);
MessageBox.Show(exists.ToString());</pre>
Vis Studio 2008 moans about comparing to itself ( a = a right?) the example I found was using integers so the line NAME.Exists(element => element > 10) translates as
element is set to equal element if element is greater than 10 so how do I convert this to use strings (my hopeful use of ToString() didn't seem to work!)
Glenn
(update: Hmm Code tags arn't working??)
|
|
|
|
|
bool exists = NAME.Exists(element => element == searchString);
|
|
|
|
|
Okay,
Thanks for that, searchString Vis Studio 2008 can't find. Is it .NET4.0 VS2010 thing or
is part of a using that I am not using or is it a hand rolled thing?
Glenn
|
|
|
|
|
Uh, that would be a variable you create to say what you're searching for.
|
|
|
|
|
|
Aaah LINQ there something...
|
|
|
|
|
I wouldn't search against the content of a GUI Control, I'd rather search some memory-based data structures (a List!) and keep my business code GUI-independent.
PS: watch the "Treat my content as plain text, not as HTML" checkbox.
|
|
|
|
|
Thanks, I am doing that (or trying to!) also I spent a little while trying to figure out
why the code was not appearing correctly,
I now have:
for (int i = 0; i <= DataPitStop.Count - 1; i++)
{
richTextBox2.Text += DataPitStop[i] + "\n";
}
DataPitStop = DataPitStop.Distinct().ToList();
it seems to be working. Can I ask is this the efficient way of sorting data (I'm guessing that they will be using cheap netbooks with some form of Windows).
|
|
|
|
|
Hmm. That code isn't sorting anything, all I see is a chronological concatenation, and the elimination of multiples.
For maximum performance:
- I would NOT concatenate strings, and hence I would not use a TextBox or RichTextBox; I prefer a ListBox, it is a line-oriented control that never needs any implicit concatenation of strings;
- I would not rely on LINQ;
- I would not get a Count property more than once (you get it on every iteration of the loop);
- I would use a foreach, not a for loop;
- I would not work on string data (as in RTB content) unless the data really is text; the actual type (int, DateTime, whatever your data is) is always the preferred one for all operations other than human input/output.
- I would prevent multiples from entering the collection, rather than removing them afterwards;
- when needing a sorted result, I would consider using a collection that sorts all by itself (depends on circumstances, may be faster or slower).
- however I would not worry a bit if Count is below say 100.
|
|
|
|