|
So you are trying to build a wizard type application.
Presumably you have the main form appear when you run the program. Some things you will need.
A list of questions
A list of expected responses/validation rules (eg ask name and get back numbers)
Somewhere to store these usually a database or an XML file
Some mechanism that tells you where you are in the list (index will do)
A container for responses, List<string> will do.
Flow
Form opens
Populate the question list
Set the current index to 0
-----------repeat here
display the text in a label for the question in list[0]
when the user clicks NEXT button validate the text in the textbox
store the response in the response List
increment the current index and repeat until all questions are responded to.
deal with the list of responses, store the info in your preferred device.
You then need to address the back operation as well (then the index is decreased clear all responses above the current one)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Teknowizard,
I am going to take your "ui" description literally and assume you really want to display a single question at a time, and I'm going to assume that you intend for the question to be displayed in the main area of the form (i.e., independently of the textbox docked to the bottom). Please correct me if that interpretation is not right.
So you have some method of showing one-question-a-time (textbox ?).
Maybe you have a timer controlling how long the question is visible ... whatever.
Now the user is typing their answer in the textbox : you are going to monitor the user's actions in the TextBox and at some point change the question.
There are many ways to do this, and I'll give you a few hints about design choices you can make with your user input textbox :
1. Multiline property of TextBox : will it be single-line or multi-line
2. AcceptsReturn property of TextBox : what will happen when the user hits the Enter key ?
3. AcceptsTab property of TextBox : what if the use enters tab ?
4. WordWrap property of the TextBox : if multi-line do you want to allow wrapping ?
Once you have experimented with and familiarized yourself with these properties, you can move on to Events of the TextBox.
Note that you could, by setting KeyPreview property of the hosting Form to true, handle key down/up/press events at the Form level.
I suggest you examine the following Events :
1. KeyDown
2. KeyUp
3. KeyPress
And consider the issue of what if the user clicks outside the TextBox : do you wish to make the Focus be restrained so the only thing the user can do is type in the TextBox : examine Events :
1. Enter
2. Leave
If you wish the user to "signal" when they are done entering an answer by some keyboard activity, you are going to need to write a Key Event Handler : start writing one now, and mess around with it, get familiar with KeyCode and/or KeyData properties of the EventArgs passed to a Key Event.
If you wish the user to "signal" they are done by some other means, well, up to you.
A few hours now of experimenting will pay big dividends for you in the future.
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
modified on Saturday, July 25, 2009 4:56 AM
|
|
|
|
|
Take the jar of baby food out of the cupboard
get a pan of water
remove lid from jar
fill the pan 1/2 full heat on stove with the jar in the water
get a spoon from cutlery draw
when baby food is warm remove from the pan
use spoon to scoop some out
feed yourself
It's a joke Bill, a joke, honest it's a joke.....
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Mycroft, I don't know why I'm laughing , but fully agree : that's funny !
My philosophy is : "why help a man to scream, when you can show him how to damn himself for all eternity."
best, Bill
p.s. there I was patting myself on the head (the one on my shoulders, I mean) for having done what I thought was a helpful thing. I thought, to use your metaphor, that I was telling the OP : "here's what you need to explore in order for your 'wisdom teeth' to come in so you can 'graduate' from pabulum."
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
It's a slow afternoon here and I seem to recall a Lounge rant against rude responders where you were given a hard time. It struck me a hilarious to see you attempting to spoon feed this person.
If I have you mixed up then I apologise but the rant and some of the reactions (Chris's reply sticky) has modified my response pattern, I now have to wait for some idiot to post a programming question in the Lounge to vent my sarcasm on.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi MyCroft,
Yep, you got me mixed up with someone else; I was the author of a strongly worded post[^] on the Site forum stating I believed people were frequently using requests for help to "take a dump on" posters on the technical forums, and this was hurting CodeProject, and was (is) just nasty pieces of work with no redeeming value.
Chris came out with the new guidelines soon after my post : of course, however, I do not believe my post was the "cause" of acton by Chris : I think he was hearing from many people on this same issue.
Don't you remember when you were a "newbie" in some technical arena, and you really didn't want someone to write your code for you, but you did need some pointing to what was really important to focus on so that you developed your understanding, were enabled to solve many problems, rather than just get a "quick fix" for a specific case you were not making progress with ?
When people have kindly replied to me here with helpful pointers when I have been stuck, I've always experienced that as "helpful enabling," not "spoon-feeding."
As I said in my long post on the Site forum : I'd like to see CodeProject, my favorite site in the whole world , my faithful old friend, my galaxy of revered gurus and teachers, have the same dynamic, evolving, kind of "tsunami" of sharing and interaction around problem solving for programmers that I see over on StackOverflow.
imho we can contribute to that partially by getting our jollies at our own expense rather than using people we don't know many of whom may not be "native" English speakers.
Let us, my friend, disprove the theory of humour espoused in the play "Comedians" by Joe Orton where he has the protagonist say, at one point : "the essence of humour is somebody else gets hurt."
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
I have managed to make use of the DwmExtendFrameIntoClientArea in Vista/7 to extend the glass effect into a form. However I cannot get this to happen on a form which is set as an mdi container. The glass portion just doesn't draw any more - it appears white. Note I'm not talking about the children inside the mdi parent, but on the actual main form itself.
Does anyone have any suggestions on how to get this working?
|
|
|
|
|
Anyone ever tried to get additional areas of glass on an mdi form?
|
|
|
|
|
Can anybody provide me links to a detail example about windows datagridview in .net 2005.
I m in urgent need of it
Thanx in adv
Shailesh
|
|
|
|
|
Have you tried the sample that MSDN[^] provides? There are also some handy "How to" links on the bottom of that page
|
|
|
|
|
|
Hello All,
Is there a way to change the background color of single word in textbox. I know it can be done in richtextbox, but i am looking for textbox.
Thanks
|
|
|
|
|
No way. Use RTB.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
RTB is heavy for my scenario, i was thinking whether can be done by overriding OnPaint/WndProc?
Thanks
modified on Wednesday, July 22, 2009 6:19 PM
|
|
|
|
|
You can paint anything you want on any Control you choose, so the Form itself, or a Panel, would be fine. Why still use a Label if it doesn't do what you want? You still need to tell it somehow which parts need which colors.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I am able to accomplish this with following code. But the problem i am facing is, when i select the text the drawn string is vanishing and the string is back to unformatted with no background color. Any ideas whats going on?
<br />
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)<br />
{<br />
<br />
Rectangle rect = new Rectangle();<br />
rect.Y = this.Bounds.Y + 2;<br />
rect.Height = this.Bounds.Height - 5;<br />
<br />
string str = this.Text;<br />
int index = this.Text.IndexOf("test1");<br />
<br />
<br />
string sBefore = str.Substring(0, index);<br />
string sWord = str.Substring(index, 5);<br />
<br />
Graphics g = this.CreateGraphics();<br />
<br />
Size s1 = TextRenderer.MeasureText(e.Graphics, sBefore, this.Font, this.Bounds.Size);<br />
Size s2 = TextRenderer.MeasureText(e.Graphics, sWord, this.Font, this.Bounds.Size);<br />
<br />
<br />
if (s1.Width > 5)<br />
{<br />
rect.X = this.Bounds.X + s1.Width - 5;<br />
rect.Width = s2.Width - 6;<br />
}<br />
else<br />
{<br />
rect.X = this.Bounds.X + 2;<br />
rect.Width = s2.Width - 6;<br />
}<br />
<br />
<br />
SolidBrush hl_brush;<br />
hl_brush = new SolidBrush(Color.Yellow);<br />
<br />
e.Graphics.FillRectangle(hl_brush, rect);<br />
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(Color.Black), (Width - Size.Width) / 2, 0);<br />
<br />
hl_brush.Dispose();<br />
base.OnPaint(e);<br />
}<br />
Thanks.
|
|
|
|
|
What do you think base.OnPaint(e); would do for a Label?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
text should be selectable.
|
|
|
|
|
I don't think OnPaint() contributes to selection.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
You can't do this in the TextBox control. However, you could create your own control that derives from TextBox and override the Paint method to do whatever you wish. Of course you'd have to come up with some way of specifying which word(s) have different colour backgrounds. Seems like a lot of work when RichTextBox already does this.
while (e) { Coyote(); }
|
|
|
|
|
in propertygrid having name property .. How to restrict user only type in name property maximum 50 characters.. how to do this..always user is enter only 50 character ..after enter 51 character don't allow to typing..
This is the code i am adding Item in propertygrid..
<Category("Misc")> <Browsable(True)> <DisplayName("(Name)")> <Description("Indicates the name of the control to identify on the page")> _
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Thanks..
modified on Wednesday, July 22, 2009 6:46 AM
|
|
|
|
|
Hi
I have written a small UserControl that, at the moment, only overrides the OnPaint event without anything else. However, the content I am drawing in the control is sometimes larger than the display-area itself, so I want to implement scrollbar-functionality that allows the user to scroll if the content does not fit the screen.
I have googled a bit for this topic, but can not find any good information, and my book only tells me how to draw UserControls, not how to implement scrollbars. Any ideas where I can get started with this?
Appreciate any help
|
|
|
|
|
Hello.
1) Put your UserControl in a new Panel .
2) Set the AutoScroll property of the Panel to "true".
Enjoy
|
|
|
|
|
i need code for retreving user DSN's which are created in system
|
|
|
|
|
C# desktop application will not start when using non-administrative user. Suspect permissions issue, but cannot pinpoint. Please help. Appears to be related to .jpg background image on main form. Here is the start of the error received (cannot reproduce in IDE, so cannot cut and paste):
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Dll was not found.
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip.Initialize()
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
<snip>
at applicationName.Properties.Resources.get_background()
at applicationName.frmMain.InitializeComponenet()
at applicationname.frmMain..ctor()
at applicationName.Program.Main()
Have resinstalled .Net framework 3.5 and set full folder and file permissions available to all users on the .net framework folders as well as to our application folder, to no avail.
Any suggestions would be greatly appreciated.
|
|
|
|
|