|
Get the first day of the month and the last day of the month ?
Below is the error code
kptDTPickerTo.Format = DateTimePickerFormat.Short;
kptDTPickerTo.Value = "01/" + DateTime.Today.Month + "/" + DateTime.Today.Year;
kptDTPickerFrom.Value = DateTimePickerFormat.Short;
kptDTPickerFrom.Value = "01/" + DateTime.Today.AddMonths(1) + "/" + DateTime.Today.Year;
kptDTPickerFrom.Value = kptDTPickerFrom.Value - 1;
modified 10-Sep-13 5:09am.
|
|
|
|
|
Where is the error code and what is your question?
Veni, vidi, abiit domum
|
|
|
|
|
I think the "error code" actually means the "code that is wrong", and I'm pretty sure his question is "I haven't bothered to step through the code, so I don't know why it's wrong".
|
|
|
|
|
Well, there are a few problems I can potentially see here. The first being what happens if the date format isn't set so that the month forms the second part of this? Your logic will go out the window. Plus, surely you just need to simplify the end date bit by subtracting one from the first day of this month + 1 month. In other words, the logic in your to picker is wrong in that you are adding 1 month to today and then expecing the last day to somehow be found out just by subtracting 1.
|
|
|
|
|
In case you're still wondering how to find the last day in the month, all you need to do is use DateTime.DaysInMonth . This is a handy method that returns this information.
|
|
|
|
|
Nothing is wrong with this code, fellas. This approach is format, Culture independent.
I've used this kind of logic many many times and its very compact.
As is obvious to all, 1st of a month is never a problem because all months have 1st.
Instead of writing yet another variant in C++/C# for "30 days hath sep...", simply add 1 to month to the variable you had for 1st of month, and then subtract 1 day from the Resulting date.
It is meant to done in date arithmetic with valid values in Date's class.
|
|
|
|
|
|
Why the default color green is not changed for progress bar control even though if change the forecolor property value to something else.it is always green by default.
|
|
|
|
|
You cannot set the color unless you remove the line Application.EnableVisualStyles(); from the main file.
This line enables the default windows color on your application.
Note that removing this line will have an impact on the entire form.
|
|
|
|
|
superselector wrote: Why From the documentation[^];ForeColor and BackColor changes for the ProgressBar will not be honored when visual styles are enabled on Windows XP Home Edition, Windows XP Professional, Windows Server 2003 and above.
You'd could paint your own progressbar, or try one the articles here on CodeProject.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I got an error when calling a secure(query string url) connection from c# code .any one got the same issue please help me.
issue : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
code :
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse webresponse = (HttpWebResponse)request.GetResponse();
request.Accept = "text/plain";
StreamReader responseStreamReader = new StreamReader(webresponse.GetResponseStream());
string response = responseStreamReader.ReadToEnd();
Thanks,
Shinu K
|
|
|
|
|
Make sure you are connecting to the url as https and not http.
|
|
|
|
|
C# vs Delphi. any ideas?
I am looking for few ideas & comments using the above technologies in,
- web based application,
- Large(which is good for future development)
- Faster(I guess Delphi)
- The development environment
|
|
|
|
|
There are even more facets to this.
For e.g.
It depends not only on your skill set but of the team you are planning to deploy.
I guess finding C# resources are better than Delhpi.
I would assume C# has a better development environment.
|
|
|
|
|
Swinkaran wrote: C# vs Delphi. any ideas? That's like meat vs. cheese on a sandwich.
Swinkaran wrote: - web based application ASP.NET would be the most widely used; meaning it's easy to get devs that are familiar with it and that there's quite some documentation.
Swinkaran wrote: - Large(which is good for future development) What is "large" in your opinion? Does it generate a huge executable? Consist of multiple projects?
Swinkaran wrote: - Faster(I guess Delphi) In converting ints and adding them to a list, yes; Delphi would be faster. C# has a better overall performance, due to things like thread-pooling.
Swinkaran wrote: - The development environment I enjoy the VS2012 IDE; haven't seen the Delphi IDE since v6.
FWIW; it's allowed to mix both languages - I'd recommend using .NET, and to plug in your Delphi-code when you find that you "need more speed" or want to juggle with pointers.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi All !
The Event of btnNext_Click in DataGridView here is my Code :
int numOfRows = dgv.Rows.Count - 1;
int index = dgv.CurrentRow.Index;
if (index < numOfRows)
dgv.CurrentCell = dgv[0, index + 1];
else
dgv.CurrentCell = dgv[0, index];
the problem is I want to use :
dgv.CurrentRow=...
to Select Current Row .the property of CurrentCell active One Cell of Current Row.
Thanks
|
|
|
|
|
I'm not sure you'll get much help on this until you write in complete sentences and explain what the problem is more clearly.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
smh1392 wrote: the problem is I want to use : That's indeed a problem; that property is readonly, meaning you cannot set it. You can set the current row by selecting it using the CurrentCel property, like shown below;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
class Program
{
static void Main(string[] args)
{
using (var f = new Form())
{
var dgv = new DataGridView() { Dock = DockStyle.Fill };
var lst = new List<Object[]>();
lst.Add(new object[] { 1, "One", DateTime.Now });
lst.Add(new object[] { 2, "Two", DateTime.Now });
lst.Add(new object[] { 3, "Tee", DateTime.Now });
dgv.DataSource = lst;
f.Controls.Add(dgv);
var btn = new Button() { Dock = DockStyle.Top };
btn.Click += delegate
{
dgv.CurrentCell = dgv[1, 1];
};
f.Controls.Add(btn);
f.ShowDialog();
}
}
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hi
how to create wordlist 8 to 16 character contain full character on the keyboard ??
|
|
|
|
|
Probably by writing some code. But you need to give a much clearer explanation of your problem if you want some help.
Veni, vidi, abiit domum
|
|
|
|
|
mory_260 wrote: how to create wordlist For which purpose? If you're looking for something that generates passwords, try a "normal" dictionary and specific character-replacements.
mory_260 wrote: contain full character on the keyboard A key on the keyboard is usually responsible for more than one type of character. One can even type characters that aren't present on the keyboard, using an alt-numeric combination or an application like Windows' charmap.
With strings containing UTF16 characters, there's quite some more characters than keys
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi there !
I want to not allow at Space the First of TextBox Like this :
TextBoxText=" Test";
in key_Pressed event i wrote this :
if ((sender as TextBox).SelectionStart == 0)
e.Handled = (e.KeyChar == (char)Keys.Space);
else
e.Handled = false;
but it doesn't work .
thanks any help .
|
|
|
|
|
Well, you never specified where this code was, so I'll assume it's in the code for the form. That;s the wrong place to put it. Normally you would put code like this in a class that inherits from TextBox and create your own version of the TextBox to use. Then this code would go into the KeyPressed event handler of this new class.
|
|
|
|
|
Let the KeyPress event execute - just trim the textbox e.g.
(sender as TextBox).Trim()
|
|
|
|
|
Almost, it would have to be:
(sender as TextBox).Text = (sender as TextBox).Text.Trim();
But you would also have to check that .Text is not empty or null first.
|
|
|
|