15,896,557 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 dsnlkc (Top 25 by date)
dsnlkc
1-Jul-11 3:13am
View
SendInput function does the trick. A little walkthrough for using it is in order, though. It might be of some help for future readers.
First of all, as BobJanova said, it is a Win API function, not .net method. On this link
http://pinvoke.net/default.aspx/user32.SendInput
you can find detail description (tutorial) about using it. You can find open source C# wrapper for this function here:
http://inputsimulator.codeplex.com/
Just add this project to your solution and you will be able to simulate keyboard entries. However, I experienced some problems with simulation of mouse clicks, so I had to implement that myself, but data types defined in the project offered me great help. I just had to add one more method to the InputSimulator class.
Thank you BobJanova for the suggestion and your time. Happy coding.
dsnlkc
1-Jul-11 3:10am
View
Deleted
No comment
dsnlkc
22-Jun-11 12:20pm
View
Thank you for your suggestion. I read about SendInput at MSDN and it seams like nice solution to my problem. However, I couldn't find instruction how to call it in my C# code, which class and namespace does it belong to, whether it is static method or not, and which reference and using directive should I add to my C# project.
Can you please answer these questions for me?
Also, if it's not much trouble, small example would be nice.
Thanks again
dsnlkc
6-Apr-11 3:21am
View
OK, you being so sure casts some new light on the TextBox/ListBox pair approach. As I already said, I tried it and failed (which isn't big surprise because I'm new to WPF). To describe the problem depicted above, I created WPF project as simple as I could. Beside files created by Expression Blend automatically I created one user control: TextListPair. The content of MainWindow.xaml file is:
<pre lang="xml"><window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:clippingIsue2" x:class="clippingIsue2.MainWindow" x:name="Window" title="MainWindow" width="640" height="480">
<grid x:name="LayoutRoot">
<scrollviewer height="70" margin="135,121,244,0" verticalalignment="Top" removed="DarkGray" width="250">
<stackpanel verticalalignment="Top" removed="#FF07C81B">
<local:textlistpair></local:textlistpair>
</stackpanel>
</scrollviewer>
</grid>
</window></pre>
and the content of TextListPair.xaml file is:
<pre lang="xml"><usercontrol xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" x:class="clippingIsue2.TextListPair" x:name="UserControl">
<grid x:name="LayoutRoot" removed="#FFBA0000">
<textbox margin="8" textwrapping="Wrap" text="TextBox"></textbox>
<ListBox Height="100" Margin="8,0,8,-91.723" VerticalAlignment="Bottom" Background="#FF7C00C6"/>
</grid>
</usercontrol></pre>
I did not make any changes to code-behind files. As you can see part of the Listbox is clipped by Scrollviewer. If there was ComboBox instead of TextListPair, its popup wouldn't be clipped. It would exceed dimensions of the Scrollviewer.
So, how can I do that with Listbox?
Alternatively, solution where the Listbox doesn't exceed dimensions of Scrollviewer, but the Scrollviewer allows scrolling so that user can scroll down to see the rest of the Listbox, would be satisfactory, too.
Thanks in advance.
dsnlkc
6-Apr-11 3:17am
View
Deleted
dsnlkc
6-Apr-11 3:11am
View
Deleted
No comment
dsnlkc
5-Apr-11 16:35pm
View
Good idea, but no. StaysOpenOnEdit property set to true keeps popup opened only when focus is transferred from the popup to ComboBox's TextBox.
Other idea is good, too, but when I use Listbox instead of popup I have following problem: ComboBox (or TextBox ListBox pair) will be part of UserControl. Popup (or Listbox) wont always be visible and when it is, it will exceed dimensions of the UserControl. That by itself is not a problem, but the UserControl will be put inside StackPanel which will be inside Scrollviewer. If I use TextBox ListBox pair, part of the ListBox that is outside of the UserControl will be clipped by the Scrollviewer. I had an idea to enlarge the UserControl (all the time or only when the ListBox becomes visible) so that whole ListBox can fit into it, but the ListBox will be collapsed most of the time and my designer says that solution isn't pretty enough.
I'm still exploring possibilities so I will take all the ideas (both yours and mine) under consideration.
In any case, thank you for your time and help. Happy coding.
dsnlkc
4-Apr-11 3:49am
View
OK, I should have been more precise in my question.
What you suggested will definitely make whole rectangle visible but will violate some other conditions of my project. The rectangle will not always be visible. Its Visibility property will be changed in some event handlers and I want Scrollviewer to adjust itself to the change. What I ultimately want to accomplish is to create effect similar to the one when Combobox expands and collapses itself (Combobox can even exceed dimensions of the window). Maybe Rectangle that exceeds UserControl's dimensions isn't the best approach and if you know better one please share it with me.
In any case, thank you for your time.
dsnlkc
23-Mar-11 9:16am
View
@Update: Never mind. I'll write it again.
Great answer. I was completely unaware of the existence of GetTemplateChild method, probably because it's protected and thus not shown by intelisense in VS.
I have just two remarks (it may be of some help to future readers). Maybe my question wasn't clear enough, but the Button is defined in ListBoxItem's template, NOT in ListBox's one, so one should create, for example, MyListBoxItem class which should inherit from ListBoxItem class, as the note above suggests.
Also, GetTemplateChild will return button object only if the particular MyListboxItem object has Template applied to it, which is (to the best of my knowledge, but I might be wrong) done by WPF internally "when it's needed". So one could be unable to get some object defined by template in constructor of MyListBoxItem, for example. The solution for that is to explicitly apply particular template to instance of MyListBoxItem before getting its "template children" with the code above.
Thanks again for the answer. Happy codding.
dsnlkc
20-Mar-11 14:08pm
View
Thank you very much, I was completely unaware of the existence of GetTemplateChild method (it is protected method so it is not shown by the intelisense). The answer is very helpful.
I have just one remark (it may be of some help for future readers). Maybe my question wasn't clear enough but the Button is defined in the ListBoxItem's template, NOT in ListBox's template, so ListBoxItem class should be derived, and the code above should be placed in that class.
Thanks again for help. Happy coding.
dsnlkc
23-Feb-11 14:08pm
View
Please see my reply to SAKryukov's comment (the first one) to your answer. It should be posted here but I misplaced it (Sorry).
dsnlkc
23-Feb-11 14:04pm
View
I'm sorry, above reply is misplaced. It should have been posted as comment to answer by John Simmons. Sorry again.
dsnlkc
23-Feb-11 14:02pm
View
I'm sorry, I don't understand your question. If you are asking whether my previous reply is related to disability of DateTime structure to represent years 10000 and later, then no, it has nothing to do with that. But that disability, as I wrote in my original question, is just one thing of those bother me. Among others are the fact that GregorianCalendar recognizes only current era and possibility of creating DateTime structure which in some timezones might be invalid, as I showed above (or I'm somehow wrong).
dsnlkc
23-Feb-11 5:34am
View
Yes, you are right. I know I can't create DateTime object which holds 44th of June or January 1st 2010. 12:123:-2, but take a look at this code:
DaylightTime dlt = TimeZone.CurrentTimeZone.GetDaylightChanges(2010);
DateTime shortDate = dlt.Start;
DateTime invalidDateTime = new DateTime(shortDate.Year, shortDate.Month, shortDate.Day,
shortDate.Hour, shortDate.Minute +1, 0,
DateTimeKind.Local);
Console.WriteLine("\nDaylight saving time for year {0}:", 2010);
Console.WriteLine("{0:yyyy-MM-dd HH:mm} to " + "{1:yyyy-MM-dd HH:mm}, delta: {2}",
dlt.Start, dlt.End, dlt.Delta);
Console.WriteLine("\nDate and time held by invalidDateTime object: {0:yyyy-MM-dd HH:mm}",
invalidDateTime);
In my time zone it will produce this output:
Daylight saving time for year 2010:
2010-03-28 02:00 to 2010-10-31 03:00, delta: 01:00:00
Date and time held by invalidDateTime object: 2010-03-28 02:01
shortDate holds date and time which is shown first in the output. That is the date when clocks moved from 02:00 to 03:00 immediately, so there was no time 02:01 on that date, yet DateTime constructor allowed me to create that last date and time held by invalidDateTime object: 2010-03-28 02:01. So if DateTimeKind of some DateTime object is set to Local, that DateTime object might be invalid in some time zones.
If I'm wrong about anything I said, please correct me.
Also, thanks for the advice to use extension methods. As I could see on MSDN they are great when some type can't be derived, whether it is a structure or sealed class. I think they alone will not solve my problem, though.
dsnlkc
23-Feb-11 5:33am
View
Deleted
dsnlkc
22-Feb-11 7:51am
View
Deleted
No comment
dsnlkc
22-Feb-11 6:38am
View
Deleted
No comment
dsnlkc
20-Feb-11 12:46pm
View
Best answer so far, indeed.
Well, it is not a game, but it might be futuristic. My application should be able to keep information of various dates (and times), both in future and in past. And I will not prevent its users from setting some date to, for example October 24th 23456. or January 1st 100. B.C. no matter how unlikely it is that someone will actually use those dates.
So, I will probably write class which has DateTime struct as its field plus 2 more fields to hold those extra years, and information about the era, or something like that.
Thanks again.
dsnlkc
9-Feb-11 14:24pm
View
Thank you Espen.
I've been looking over database types you suggested and I think SQLite is the best suited to my needs. I wonder why did you say not to use it if I can avoid it? If you said so because it is "serverless" and "zero-configuration", as it is written on its home page, than I still think it suits me best, because I intend to use it just to store some data in it, data that is relevant only to my application. In other words my application will use it pretty much the same way Microsoft Word uses *.doc files, so if you think that database of some other type will better fit those needs, please tell me.
Also I would appreciate if you recommend me some documentation or tutorial about using SQLite in C#.
Thanks again.
dsnlkc
6-Feb-11 13:19pm
View
This is very interesting, too. When I use some project templates I can't find entry point (aka Main() method). What should I do to make visual studio show me all the code it generated?
dsnlkc
6-Feb-11 13:12pm
View
First answer is pretty much what I expected. Thanks for the tip on user interface design; minimalistic (in the sense of quantity of windows) user interface is more to my liking, too. Second answer was an enlightenment. You saved me A LOT of time. I think I have all I need in order to write my application now, but if something related come up I will post the question here as a reply.
Thanks again and happy coding!
dsnlkc
6-Feb-11 5:35am
View
Have you ruled out Access only because of the lack of views and stored procedures? My program will not be too complex and time consuming so stored procedures could be replaced with queries and I probably will not use views anyway, so Access would still be one option.
dsnlkc
6-Feb-11 3:38am
View
Great answer. Thanks.
Application class seems to have some really nice functionalities. I have two questions, though.
How to add newly created window to its Windows property?
How to hide the console which shows before the first window?
Thanks again.
dsnlkc
6-Feb-11 3:28am
View
My purpose of not using "WPF Application" project template to create my window is that I do not know what it should look like at compile time, so I need to parse some XAML at run time to create it. I don't think that "WPF Application" project template offers such functionality, but I might be wrong and if I am, please correct me.
dsnlkc
5-Feb-11 7:28am
View
Thanks. That saved me a lot of time. First method I understand (I thought I would have to do something like that), but now I'm intrigued by that method which involves compiling and loading compiled code at runtime. Could you elaborate it a bit more, or give me link(s) to some documentation? I didn't know that it is even possible so please include the very basics, too.
Thanks again.
Show More