|
In a combo box the items are just strings so you can do this:
foreach (string itm in comboBox1.Items)
{
MessageBox.Show(itm);
}
HTH
|
|
|
|
|
MCSD-Gandalf wrote: In a combo box the items are just strings...
Not always true.
The Items property is an ObjectCollection because you can stuff whatever you want in the collection, and render the Items yourself in a custom drawing routine. It's usually strings, but not always.
Share and enjoy.
Sean
|
|
|
|
|
Very true.
Of course HOPEFULLY if you have stuffed something else in there you know what it is and can write the appropriate foreach loop. And if not I guess you can always treat everything in there as an object and write the foreach loop that way.
Guess I need to be a bit clearer around here with all you guru's watching !
Thanks!
Gandalf
|
|
|
|
|
MCSD-Gandalf wrote: Guess I need to be a bit clearer around here with all you guru's watching
The comment wasn't so much for you; it was intended for people who are less well informed who may read the thread later. I don't usually presume to correct MCSDs.
Share and enjoy.
Sean
|
|
|
|
|
I want to ask that if I want to go to last child folder of any root folder..How can i do that...?
Following example will help to understand my prob.
like- c:\Data\Data1\Data2\Data3
c:\Data\Data1a\Data1b\Data1c
in this data is root folder in which if has 2 sub folders.
Now i want to reach folder Data3 and Data1c
foreach (string directory in Directory.GetDirectories(folderPath))
By using this code I can reach upto Data folder not inside of this folder.
This will help u most.
Thanks,
Hitesh
Hitesh Mangal
|
|
|
|
|
try this:
string temp= folderpath.Substring(folderpath.LastIndexOf("\\"));
this will get u the name of last folder...
then use it in what ever way u want..
abhinav
|
|
|
|
|
Friends,
I am creating a dialog box using Windows Forms. I want a *default button* on my dialog box i.e whenever user presses *enter* key, the button even gets processed. But i don't want my dialog box to get closed on the button press event, instead it should perform some custom task. How can i do so ?
Imtiaz
|
|
|
|
|
try to use
forms AcceptButton property to set default button
rahul
|
|
|
|
|
Hello all,
pls i wanna need know if i created 5 new instance of a class when .net make allocation for these objects does the memory location for each new object consists of its attributes only and in this case th methods for the five objects in memory exists all only once and each of the five objects can call them OR for the five instances each one has the same code of methods exist separetly (i.e the code for methods exist in memory five times each one within each instance's memory space)
??????????????????
|
|
|
|
|
Please use punctuation to separate the sentences from each other. It would make what you write much easier to understand. (Perhaps you should have someone look at your keyboard too, the question mark key seams to get stuck. )
The methods exist only once in memory.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa wrote: The methods exist only once in memory.
But mostly twice (unless inlined)
|
|
|
|
|
thanks alot for ur answers . it really helped me more
|
|
|
|
|
i want to use a function defined in a win32 dll.
which is defined as below:
void Func1(int a,int b,USHORT ** VarArray);
in C#, which data type should i use for the parameter " USHORT ** VarArray "?
|
|
|
|
|
I suppose ushort [][] VarArray
|
|
|
|
|
i have the dllimport as below:
[DllImport("DS40xxSDK.dll")]
private static extern int SetOsdDisplayModeEx(IntPtr hChannelHandle,int color,bool Translucent,int param,int nLineCount,ushort[][] FormatArray);
and call it as below:
private void myFunc()
{
int number=OSDStrings.Length;
ushort [] [] FormatArray=new ushort[number][];
for(int i=0;i
|
|
|
|
|
I have a treeview which lists all the chapters of a book. Whenever the treeView is selected, the program is supposed to paint the text of the entire chapter onto a tabpage.
*******************************************************************************
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
// a query is run here to produce a result of text from a certain chapter and then import it to a chap_lines string array
tabPage1.Paint += new PaintEventHandler(tabPage1_Paint);
}
private void tabPage1_Paint(object sender, PaintEventArgs e)
{
y = 8;
Graphics g = e.Graphics;
foreach (string line in chap_lines)
{
g.DrawString(line, new Font("Courier New", 10, System.Drawing.FontStyle.Regular), new SolidBrush(Color.Black), 3, y);
y = y+20;
}
}
*******************************************************************************
The problem is that the text is not painted until the next chapter node is selected. Chapter 1 is okay as it is the default node. But if I then select chapter 3, those text of chapter 1 stay there. The text of chapter 3 is not displayed until another chapter is selected.
The thing is when I debug the program setting the breakpoint at "tabPage1.Paint += new PaintEventHandler(tabPage1_Paint)", it gives me the correct result. But if I set the breakpoint anywhere in the tabPage1_Paint event, it can never get out of itself. Why is that?
How can I display its correct text once a chapter is selected?
Also, I have set the tabPage1.AutoScroll to true but it still doesn't scroll to display those lines that are not visible to the tabPage1 area.
-- modified at 22:07 Tuesday 6th June, 2006
|
|
|
|
|
Don't add the eventhandler to the paint event from the AfterSelect event. That should be done only once, preferably in the Load event. Now you are adding a new handler every time you select a chapter, which means that the tablPage1_Paint will be called multiple times whenever the control needs to be redrawn.
To cause a control to be redrawn, you use the Invalidate method of the control.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks!
But I want the user to choose what chapter they want to read. If I put the eventhandler in the Load event, it would happen only once??? Well, I think I can do it for the 1st chapter (as default page) but how about the rest of the chapters?
|
|
|
|
|
You are confusing hooking up an event with using an event.
Adding an event handler will hook up the method to the event, but it will not call the method. If you do this more than once, the event will contain more than one hook to the same method. That means that every time the event is used it will call the method more than one time.
The paint event is used automatically whenever the control needs to be redrawn. You don't use the paint event yourself. If you need the control to be redrawn you use the Invalidate method to tell the system to redraw the control.
---
b { font-weight: normal; }
|
|
|
|
|
Yes, I was confused as I'm new to C#. Anyway, I've got it working now - thanks for your help.
Could you please also advise what I can do to make the tabpage scrollable (tabPage.AutoScroll = true doesn't work and I've got missing text - those painted beyond the visible area)?
-- modified at 7:48 Wednesday 7th June, 2006
|
|
|
|
|
Are you sure that it doesn't work? Do you have any contents in it that would make it scroll?
---
b { font-weight: normal; }
|
|
|
|
|
It worked if I used labels to display text instead of painting it using graphics object. Would it be that the painting on the tabpage cannot be scrollable at all???
Someone suggested to add a label outside the visible area on the tabpage. It makes the tabpage scrollable but when I do a scroll, the painting becomes messy.
Also, it can only be scrolled down to the y location of the label. It is still a problem if the text to be displayed is beyond it.
Any suggestion for this fix?
|
|
|
|
|
The scrolling area is decided by the size needed by the child objects. The graphics you draw is no child objects, so it won't affect the scrolling area.
To get the scrolling area to be the size you need, you have to put a child object in the tabpage. Either place the child object at the position of the last line you draw, or place it at the top and resize it to the size of what you draw.
Perhaps you should make a special control to draw your text on, instead of drawing on the tappage. That would make it easier to handle scrolling also.
---
b { font-weight: normal; }
|
|
|
|
|
It works now. I have added a panel on a tabpage and have the text painted on the panel.
Thank you very much for your help.
|
|
|
|
|
How can I bind one ComboBox to another having a 2 table dataset with a relation created? I would like to view in second Combo only these records which have equal key to the record selected in the first one.
|
|
|
|