|
Thanx Davey.... Im going to try the listbox.. Like i said ive NEVER used any Visual C# before so all i know is textbox thru watching youtube videos lol...
To be honest this program im doing is to get accepted into a class to learn Visual C#.. By completing this satisfactory Ill get the opportunity to learn the Language for free.. With this recession going on free always sounds good.....
so Im just tryna feel my way thru with trial and error.. if this was Pascal i would have been finished lol but i guess u can see how outdated i am
|
|
|
|
|
textbox2.Clear();
string input = textbox1.Text;
for(int i = 1; i <= 26; i++)
{
char letter = (char)(64 + i);
int count = 0;
foreach(char c in input)
{
if(char.ToUpper(c) == letter)
count++;
}
textbox2.AppendText("There are " + count + " " + letter + "'s" + Environment.NewLine);
}
...this can be called from you button event handler... easy
Life goes very fast. Tomorrow, today is already yesterday.
modified on Tuesday, May 12, 2009 10:20 AM
|
|
|
|
|
First off the idea is to give points as it is homework and second I would look at your solution again as it's messy. You end up doing 26 loops over the length of the string!
Think of a different way, use a list or dictionary.
|
|
|
|
|
hopingToCode wrote: First off the idea is to give points as it is homework
what else can demonstrate a solution as good as an example?
hopingToCode wrote: I would look at your solution again
So if you would look at my solution again then you must like it
hopingToCode wrote: You end up doing 26 loops over the length of the string!
Guess what, I wrote it so I already know its not the best solution, the point was it was short code to exemplify a possible solution
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
To be honest this program im doing is to get accepted into a class to learn Visual C# so its technically not a homework assignment because im not in a class.....
By completing this satisfactory I'll get the opportunity to learn the Language for free.. With this recession going on free always sounds good.....
Ive never coded in visual C#.... ive done some Pascal and C in HS ive just been tryna teach myself because i came across this opportunity to be taught the Language for Free...
I really appreciate everyone's help... but if someone will tell me how to keep my reults from being displayed on one line ill be the happiest guy on the planet
|
|
|
|
|
Mo Chips wrote: how to keep my reults from being displayed on one line
If you use a ListBox as suggested earlier then assuming your ListBox is called listBoxResults and your text is in a string called yourResultString then:
listBoxResults.Items.Add(yourResultString); Doesn't get much easier.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I understand what you're saying but it's also bad to get into bad programming habits, so better to optimism as much as possible.
I just had a go at doing it and it took me about 10 min
|
|
|
|
|
Its displaying the results all on oneline... how do i get it on seperate lines??
|
|
|
|
|
sorry... see the edited code.
But adding a new line in a string is something you should know before doing anything like this... so if you are willing to learn as you said then you should go to whomever set the homework and ask for some good book/websites for the basics.
...or you could use a listView then you wouldnt need the newlines
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi there,
Is there a way to have the TabControl on a WinForm without showing the Tab header?
Kind regards,
Jr
|
|
|
|
|
Yes, use a panel!
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Why would you want to?? You could just use different panels!
|
|
|
|
|
I think Ashfield and hopingtocode are (understandably) confused as to why you want to do this. If you created a TabControl without a tab header, how is the user going to select the tab division they want to veiw?
What are you trying to achieve?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Well, I'm trying to create a wizard like interface. I will then add a Next and Previous button and provide the user with the ability to navigate through the pages.
|
|
|
|
|
There are some wizard controls out there but I would use panels to do the information display. Tab is for when you want them all viewable
|
|
|
|
|
OK. Create a form, with a panel which occupies most of space, leaving enough for your buttons - lets call it panelSpace.
Create your individual panel fillers by Project...Add...NewItem... UserControl - this creates a blank panel filler - lets call it panelA. Set its Dock property to fill the panel, and place your controls.
When you want to display the items from panelA:
panelSpace.Controls.Clear();
panelSpace.Controls.Add(panelA);
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
OriginalGriff wrote: Set its Dock property to fill the panel,
No I'm an idiot - it doesn't have a dock property - ignore that bit! Must be a tuesday again...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Thanks Original Griff for this. This works!
|
|
|
|
|
You're welcome.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Try that derived class form TabControl. It simply overrides the DisplayRectangle and adds a ShowTab Property for your new TabControl class. Does it help you ?
public class MyTabControl : TabControl
{
public override Rectangle DisplayRectangle
{
get
{
if (showTabs)
{
return base.DisplayRectangle;
}
else
{
return new Rectangle(0, 0, Width, Height);
}
}
}
#region Properties
private bool showTabs = true;
[Category("Apparence"),
Description("Indique si les onglets s'affichent."),
DefaultValue(true)]
public bool ShowTabs
{
get { return showTabs; }
set
{
showTabs = value;
RecreateHandle();
}
}
#endregion
}
|
|
|
|
|
Pyrrhon you're a Genius - your answer was exactly what I was looking for. Thank you again.
|
|
|
|
|
I'm glad to help you. Just a little thing : when you add a lot of TabPages, 2 tabpage scroll buttons appear in the TabControl. To hide them, just set Multiline=true. However I suppose you knew it.
Bye
|
|
|
|
|
Hi,
In my project I have to place the existing user controls dynamically on a form at the given location. That is I will give the X-axis and Y-axis values in the text boxes dynamically then the existing user control should be dynamically created at that location.
If any one have any idea to solve this, please reply me as soon as possible.
Thanks in advance.
|
|
|
|
|
This is quite trivial, you should buy a book and read it. The Petzold book is good in this regard.
You add the control to the form's controls collection and you set it's position.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
If using 2.0 or above you can use a generic function such as this in your form.
private void AddControl<T>(string text, Point location, Size size) where T : Control, new()
{
T control = new T();
control.Text = text;
control.Location = location;
control.Size = size;
this.Controls.Add(control);
} and call it like
AddControl<Button>("New Button", new Point(12, 12), new Size(75, 23));
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|