Jump to content

C# help?

- - - - -

  • Please log in to reply
25 replies to this topic

#1
Microguy

Microguy

    Newbie

  • Members
  • PipPipPip
  • 30 posts
How do I make automaticly numbers like
1.
2.
3.
etc.. in listBox? for example I have
listBox1.Items.Add ("item1"); in a button.
when I click it it automaticly show up a 1. and in the next button
it comes a 2. so at the end it says

1.item1
2.item2 etc..

Edited by Microguy, 04 December 2011 - 02:44 AM.
New question


#2
TheCompBoy

TheCompBoy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 272 posts
I don't understand your question.. Could you explain a little bit more?
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/

#3
Microguy

Microguy

    Newbie

  • Members
  • PipPipPip
  • 30 posts
when I have a listBox and type something, it automaticly come a 1. in the first line, and if I start on a second line, it comes 2.
That will be very useful for what im making :)
I hope you understand :)

#4
TheCompBoy

TheCompBoy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 272 posts
Ahhhh!!

Now i get it.

Here is an article that has exactly the thing you're looking for:
Numbering lines of RichTextBox in .NET 2.0 - CodeProject

And here is another i just found.
LineNumbers for the RichTextBox - CodeProject
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/

#5
Microguy

Microguy

    Newbie

  • Members
  • PipPipPip
  • 30 posts
richtextbox..? ok, thanks but I was looking for listBox :)

#6
TheCompBoy

TheCompBoy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 272 posts
Here is two solutions i found for ListBox:

1) ListBoxRowNumbers lets you add Row Numbers to your ListBox or Combo control
ListBoxRowNumbers

2) Add line/row numbers to the underlying rowsource.
RowNumber
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/

#7
Microguy

Microguy

    Newbie

  • Members
  • PipPipPip
  • 30 posts
hmm, i downloaded it, but where do I place the file and use the code?

#8
TheCompBoy

TheCompBoy

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 272 posts
I can't answear that question, Sorry..

The point is that you should read the page through and the code too and learn from it.
I don't do copy & paste so i can't help you on that one.

Hope that you understand.
Think my post we're usefull? Please take your time and press the Like button at my post, Big Thanks!
For great C# & Android tutorials visit my blogg: http://www.thecompboy.com/

#9
lespauled

lespauled

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 231 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash
Are you familiar with "for" loops?

If so, you can easily create what you are looking for by seeing the sequence you have listed above:

1.item1
2.item2

there is a distinct pattern. I would use string concatenation to create each item.

#10
Microguy

Microguy

    Newbie

  • Members
  • PipPipPip
  • 30 posts
Hmm, im sorry but what do you mean?

Edited by Microguy, 06 December 2011 - 09:29 AM.
Bump


#11
lespauled

lespauled

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 231 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash
I mean, have you learned "for" loops yet.

A simple for loop will allow you to add the number to the front and back of each text item, then add them to the list.

#12
Microguy

Microguy

    Newbie

  • Members
  • PipPipPip
  • 30 posts
Uhhm, no :P

Edited by Microguy, 08 December 2011 - 05:44 AM.
Bump





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users