|
What exactly are you trying to do? If you're just trying to display a date and not let them pick a date, then just format a DateTime to the stirng format you want:
label1.Text = DateTime.Now.ToString("m"); For more information about the format codes allowed for DateTime.ToString read about it in the .NET Framework SDK, which is installed by default with VS.NET and is available online at http://msdn.microsoft.com/library[^].
If you disable the calendar, how is the user to pick a date? Yes, they can use the arrow buttons but many people don't know about that and it is cumbersome to use.
Do you only want to disable the year selection of the calendar? While not impossible it's not supported by the calendar control (which is actually the native Month Calendar control from Windows Common Controls) and you would have to go to quite a bit of work to clip it or hide that portion of owner-drawn content and to not allow notification messages to be sent when actions occur over those coordinates (like a mouse click).
If you want to allow the user to only see the month and day, then use a custom format by setting the DateTimePicker.CustomFormat property and in the code that uses the DateTime ignore the year.
Other than that you'll need to develop your own control.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I wanted to only allow the user to pick a month and a year. I do not need to use a date.
|
|
|
|
|
Anonymous wrote:
I only need to use the month and the date...
Your first statement was rather ambiguous.
Still, though, there is no support from the Common Control (and, hence, none in the Windows Forms control that encapsulates it) to hide the day select either.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have just started this. and i m trying to make a chat application that runs over LAN.
there might be many other ways and they might be better then using Udp port but i want to understand this thing. i have read some articles before posting but i m now having problem on receiveing messages.
public void waitData()<br />
{<br />
while(true)<br />
{<br />
IPEndPoint from = new IPEndPoint(IPAddress.Any,170);<br />
<br />
<br />
string result = "";<br />
Byte[] drec = receive.Receive(ref from);<br />
result = Encoding.ASCII.GetString(drec);<br />
textBox1.Text = result.ToString();<br />
<br />
}<br />
}
this code is to recieve messages and i made a thread so it keep waiting for any message to recieve. and i m broadcasting message to network.
i m new to this so plz help me
i think its enough to explain what i want to do but if still you think i had to tell more. tell me.
|
|
|
|
|
So what's the problem?
Also, don't keep reinstantiating your IPEndPoint in your while loop. You only need to do this once per end point required for your application.
If you're having trouble using UDP classes in .NET then be sure to read about them in the .NET Framework SDK, like the UdpClient[^] class. Many of these include examples and reading about what the methods and properties actually do is important.
The documentation I've linked in particular shows you how to send and receive buffers using the UdpClient .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Dear all
I am supposed to develop a application in both English & Arabic in C# 2003. My doubts is, do I have to create all the forms, message boxes in Arabic also (By Mirroring). Does it mean that my application will have duplicate forms. One for Arabic and One for Non-Arabic. I am using SQL Server 2000. How will the Arabic Forms be written in the database? Can i be able to recognise/Display like normal characters in other application?
If any of you have faced/solved such issues, please help me out. If possible
hint me some references also.
Thanks in advance
Chandru.
|
|
|
|
|
|
You need to localize your app so that no text is entered directly onto the form.
You don't want to have to code more than one copy of the same form. If you are careful you need only make one form that is modified at run time to display the correct text.
We completely ignored the Microsoft localization techniques because they expect you to provide localized resource files with your app which for us won't work because we have users that may want to work in different languages in the same office and switch at will and we also wanted to make it very easy for our users to not only make their own language text but be able to modify the stock ones for their own business. I.E. if a field says "Date of employment" in english they might want to change that to "Date hired" or what have you. We figured that since we were going to localize we might as well make it even more useful for the users who often like to make these little changes if they can since terminology varies so much even across english speaking countries.
You may be able to use the more traditional methods referred to in that resource someone else pointed you to, however keep in mind they are static and not flexible.
What we did instead is we put keycode strings into the text properties for controls. For example on a customer form with a date field on it, instead of having a label with the text DATE in it, we put in "Customer.Label.Date". Then when the form is opened we have a static code that substitutes on the fly the correct string before displaying to the user.
All our language strings are stored in a database and loaded into memory when a user logs into our app so they can be displayed as required. No where in our source code are there any hard coded strings, simply keycodes instead.
In your database you must ensure that you are using all the unicode compliant versions of sql server table field definitions. I.E. use NVARCHAR instead of VARCHAR.
|
|
|
|
|
Hello!
I've been trying to figure out how to work with the VS 2005
client/application settings but I can't make it work.
I can go to the project properties and choose the settings tab where I
can enter different settings. But I can't change it att runtime.
If someone could be nice enough to give me an code example of how I
could enter a setting, change it at runtime and save it, I would be
very grateful!
Thanks in advanced!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Those settings are changed through the .config file for the application, which is located in the same directory as the application and with the same filename with ".config" appended.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello =)
Thanks for answering but I know they are in there, but you shouldn't have to change the values there with xml types. If you let VS make the settings class it creates a class called Settings that inherits from ApplicationSettingsBase. You can also make your own class and inherit from ApplicationSettingsBase, and then add a property for every setting.
Read more about this here:
http://msdn2.microsoft.com/library/0zszyc6e.aspx
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Yes, I'm well aware of that.
VS 2005 is in beta, and there's a lot that doesn't work. We're nearing beta 2 when much more works but can release no further details about when beta 2 is due to release.
For now you have to change the settings through the .config file as you do for .NET 1.0 and 1.1 or write your own SettingsProvider which is responsible for serializing the ApplicationSettingsBase class (and its derivatives).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello again!
Well, I've tested some more and if I use user-scoped settings I am able to change them and save them.
=) Thanks for the answers!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
I have tried the above solution .
but if i give File.AppendText(Path) then it will append it at the end
so what to do?
|
|
|
|
|
Try the following:
using (StreamWriter sw = File.AppendText(Path))
{
sw.BaseStream.Position = 1;
sw.WriteLine("Hello World");
}
www.troschuetz.de
|
|
|
|
|
I tried out the code but i got a runtime error at sw.BaseStream.Position=0;(It is zero based).
System.IO.IOException: Unable seek backward to overwrite data that previously existed in a file opened in Append mode.
what to do?
Sukanya
|
|
|
|
|
I took a deeper look into the documentation and think you'll have to use one of the other suggested solutions.
The File.AppendText(path) method is equivalent to StreamWriter(path, true) . The boolean parameter append "determines whether data is to be appended to the file. If the file exists and append is false, the file is overwritten. If the file exists and append is true, the data is appended to the file. Otherwise, a new file is created."
So in the current solution, append is true and seeking backward is forbidden. By replacing File.AppendText(path) with StreamWriter(path, false) you should be able to seek backward, but as the above text state the existing file content will be overwritten.
Sorry and more luck with the other suggestion
www.troschuetz.de
|
|
|
|
|
The word "Append" literally means "Add to the end" - so they have named this method correctly it seems.
With the lack of a "Prepend" method, you will need to use the above solution of setting position to zero and using Write or WriteLine
|
|
|
|
|
Hello gurus,
I would like to know how I can process the Key events in a dialog box?
I have controls (buttons, radio buttons etc.) in my dialog box and I have to process the Left/Right/Down/Space keys. The problem is that when I override the OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e) method of the form, the focus of the controls in my form moves while I press the arrow keys... got it?
So, how can I avoid the process of the default behaviour of these keys?
In MFC a simple PreTranslateMessage was there, but in C#... how to to that???
Thanks for the help.
Best regards.
There is no spoon.
|
|
|
|
|
|
is there a simpler way?
There is no spoon.
|
|
|
|
|
If you need the form to process all key events for any controls, then set Form.KeyPreview to true .
While the other controls have focus and without KeyPreview being set the messages are handled only by the active control's message handler (WndProc in managed code).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
ah, ok it works.
now no matter the control I insert, the form handles the KeyDown event
thanks.
There is no spoon.
|
|
|
|
|
hi all,
I have an application, where there is a service manager which is responsible for controlling three services. The three services (which r controlled by service manager) have exe files. I have installed these three services using the installutil.exe . Now, i cannot install the service manager in the same way as I installed the three services because service installer is not present for the service manager application.
What i have to do now, Should i add installer to the service manager application and install it using installutil.exe....... if, so , how are the other three services controlled by this application.......
|
|
|
|
|
I'm not sure I fully understand your question. Is the service manager project, itself, a service? If it is, then yes, add an installer project for the service project, compile it and install it.
If, however, the service manager project is just a standard executable or a web project (doubtful), then it should be possible to compile and execute the manager from the windows desktop.
As to how the other three services are controlled by the manager, you would need to provice more implementation details about the service manager project for me to answer that question.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|