-
March 23rd, 2012, 12:42 PM
#1
Adding Text to a ListBox
Using C# only, I have made a ListBox with TextBoxes (of Zone Descriptions). Works fine. How can I add Text in front of the TextBox that says Zone 1, Zone 2, etc'? I have created both TextBlocks and Strings, but can't get the Text to appear.
-
March 23rd, 2012, 03:32 PM
#2
Re: Adding Text to a ListBox
Originally Posted by dodge55
Using C#[...] TextBlocks and Strings, but can't get the Text to appear.
This sounds like wpf
In wpf, you must have a main container, inside which you can have other stuff and even nested containers.
You should have your controls hosted in a container.
You need to show us some of your code to get more help, but you can also find a sample of that stuff here
http://stackoverflow.com/questions/9...x-with-textbox
Last edited by Cimperiali; March 23rd, 2012 at 03:35 PM.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
March 23rd, 2012, 06:54 PM
#3
Re: Adding Text to a ListBox
It's not WPF. It's only C#. I use WPF for some controls, but I want to use on the fly C# for different arrangements of the screen space. My code is:
ListBox LBZoneDesc = new ListBox();
LBZoneDesc.Width = 300;
LBZoneDesc.Height = 240;
Grid.SetColumn(LBZoneDesc,0);
Grid.SetRow(LBZoneDesc,2);
ListBoxItem[] LBI = new ListBoxItem[64];
for (byte i = 0; i < 5; i++)
{
TBlkZoneDesc[i].Margin = new Thickness((i*10), 10, 0, 0);
LBI[i] = new ListBoxItem();
LBI[i].Padding = new Thickness(3);
LBI[i].Margin = new Thickness(50, 0, 0, 0);
LBI[i].Content = TBxZoneDesc[i]; // TextBox of User entered Zone Desc.
// LBZoneDesc.Items.Add(TBlkZoneDesc[i]); // TextBlock of 'Zone i'
LBZoneDesc.Items.Add(LBI[i]);
}
C0Grid.Children.Add(LBZoneDesc);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|