|
Thank you for your replies.
I also have to test to see if the directory file path does not = 'CUST', in the directory path called ""C:\RData\CUST\Omaha\book.xlsx". How would you code that change?
|
|
|
|
|
Uhhhh, you're question isn't really clear, but wouldn't the same test work with just the smallest change??
if (filesaveLocation.Contains(@"\CUST\") == false)
|
|
|
|
|
Morning Dave!
Do you need more coffee?
if (!filesaveLocation.Contains(@"\CUST\"))
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
It was WAY past my bedtime.
|
|
|
|
|
|
You're welcome!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Note that what you are doing here (and what the replies show you how to do) is checking for the presence of a string within another string.
Checking for the "validity" of a Directory, its actual existence, when your program is running, before you take some action, like writing a file to that Directory, is another thing. .NET hands you some excellent tools for checking whether Directories, or Files, actually exist.
The System.IO library offers a host of static methods such as File.Exists("file path"), Directory.Exists("directory file path") to check run-time existence. And, for more complex purposes, you can create an instance of a DirectoryInfo object, which has Properties like .Exists.
There are several reasons that these functions could return 'false: some are obvious, like the fact that the Directory/File doesn't exist any more; others more subtle, like you have some invalid character in the path name.
Based on your questions, I suggest you get a good basic book on C# programming, and study the different operators you can use with a 'string object.
And then, think about what you are going to do if the string you have in your Application Settings is incorrect: that will take you into studying the tools offered by the System.IO library.
Study, experiment, practice, analyze your errors: learn
yours, Bill
“Humans are amphibians: half spirit, half animal; as spirits they belong to the eternal world; as animals they inhabit time. While their spirit can be directed to an eternal object, their bodies, passions, and imagination are in continual change, for to be in time, means to change. Their nearest approach to constancy is undulation: repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis
|
|
|
|
|
Hi
I have a to make space invaders for school.
I can move the defender with the mouse and he also shoots with a mouse click but I also want to use the keyboard keys left, right and spacebar.
I don't know how to start for this, please help!
Thank you!
|
|
|
|
|
|
You don't have to do my homework :s I just can't find how to use keyboard keys instead of a mouse control...
This is my project http://pastebin.com/DVewwGmz[^]
|
|
|
|
|
Well, then, it looks like you haven't looked through the list of events for the Form class. I wonder what the KeyDown and KeyUp events are for...
|
|
|
|
|
|
Thank you Collin Jasnoch I will try that!
|
|
|
|
|
Hi All,
The Pen and the Brush objects' Color property needs to be set when they are created. The problem is the color values one can use is very limited. Is there a way to send the color code to the Pen or the Brush object dynamically after choosing a color from a palette? Thanks in advance for your reply.
modified 23-May-13 7:03am.
|
|
|
|
|
You do that by creating a new Pen/Brush with that selected color (do not forget to Dispose() of the old Pen/Brush objects for freeing the resources).
|
|
|
|
|
Hi, thanks for responding. I was already aware of setting the color of the pen or the brush object using the Color.color name method. What I would like to do instead of using color names such as blue, green, red, etc. is pass in the RGB code to the property like the following
Pen myPen = new Pen;
myPen = System.Drawing.Color.F08080;
modified 23-May-13 7:04am.
|
|
|
|
|
Have a look at the FromArgb[^] method of the Color struct, you can set it to anywhere in the 32bit ARGB range. So, you set the Color and pass that to the Pen...
Edit:
using(Pen pen = new Pen(Color.FromArgb(0)))
{
}
replacing the zero with the value you want
|
|
|
|
|
Hi, thanks for your reply. The example in the MSDN below suggests that I must manually set the value of
FromArgb():
public void FromArgb4(PaintEventArgs e)
{
Graphics g = e.Graphics;
// Transparent red, green, and blue brushes.
SolidBrush trnsRedBrush = new SolidBrush(Color.FromArgb(0x78FF0000));
SolidBrush trnsGreenBrush = new SolidBrush(Color.FromArgb(0x7800FF00));
SolidBrush trnsBlueBrush = new SolidBrush(Color.FromArgb(0x780000FF));
}
You've just given me an idea; I'm going to allow users to set the color of the brush or pen object by clicking on the color palette object. This will grab the color code then pass it as a parameter to the FromArgb4() method.
modified 23-May-13 7:03am.
|
|
|
|
|
That's the correct way to do it.
Make sure you put all those brushes in using block(s) or explicitly call Dispose() on each one before you exit your method - unless you are caching them in private fields, in which case you need to make your class IDisposable and implement the Dispose pattern.
|
|
|
|
|
Hi,
I need an additional button including a handler in a System.Windows.Forms.SaveFileDialog() to do customized processing instead of a "Save" as implemented by default. To complicate matters, this dialog is opened from within WPF since WPF itself lacks such dialog.
What are the pieces needed to implement such custom SaveFileDialog(), please?
Thank you!!
|
|
|
|
|
You will need to build your own dialog, just like any other dialog you would build. So you will need to identify the controls you see in the system dialog and reproduce that yourself.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You cannot do much with the existing control.
|
|
|
|
|
Create your own custom dialog class that inherits FileDialog [^].
Use the best guess
|
|
|
|
|
|
i search google first to get any ready made sample for numeric pager for win form but unfortunately i found none. many exist for web application. so i have decided to develop my own. i have take one user control and i want to add some label on the user control at run time for simulating numeric pager link.
like << < 1 2 3 4 5 > >>
here is my code so far
public partial class PagerBar : UserControl
{
public PagerBar()
{
InitializeComponent();
}
int totalrecords = 0;
public int TotalRecords
{
get { return totalrecords; }
set { totalrecords = value; }
}
int recordsperpage = 0;
public int RecordsPerPage
{
get { return recordsperpage; }
set { recordsperpage = value; }
}
int curpage = 0;
public int CurrentPage
{
get { return curpage; }
set { curpage = value; }
}
int maxpagerlink = 0;
public int MaxPagerLink
{
get { return maxpagerlink; }
set { maxpagerlink = value; }
}
public bool HasPreviousPage
{
get
{
return (CurrentPage > 1);
}
}
public bool HasNextPage
{
get
{
return (CurrentPage + 1 <= RecordsPerPage);
}
}
int pagecount = 0;
public int PageCount
{
get
{
pagecount = TotalRecords > 0 ? (int)Math.Ceiling(TotalRecords / (double)RecordsPerPage) : 0;
return pagecount;
}
}
public void BuildPager(int CurrentPage)
{
if (CurrentPage >= MaxPagerLink)
{
}
else
{
}
}
}
my first prev,next & prev button will be fixed. i will not generate these button at run time. i want to generate only numeric link like 1 2 3 4 5 etc at run time on user control.
one thing i need to fix that number of pager bar is will be fixed in my case and that is 5. i want to show always 5 pager link like 1 2 3 4 5 or 6 7 8 9 10 etc.
suppose total records is 36 and i want to show 10 records per page so 4 pager link i need to generate at run time. the right logic is not coming to my mind to generate pager link in such a way if number of records is 110 then everything should be handle properly. if total records is 110 and records per page is 10 then total pager bar should be 11 but i want to show only 5 at a time. first time 1 2 3 4 5 when user click on 5th pager bar and next time click on next button then pager link will be 6 7 8 9 10. this way i want to show pager link but right logic is not coming to mind to generate the way i want to display pager link. it will be great help if some one help me to handle generation of 5 pager link always.
tbhattacharjee
|
|
|
|