|
Hello Luc,
Thanks for your response. I am afraid i didnt quite understand what you meant.
Could you please elaborate or point me to any other link?
Thanks
D
|
|
|
|
|
These are the keywords you need (for either ListBox or ComboBox):
DrawMode, DrawItem, and maybe: MeasureItem
I suggest you read up on them.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
Hello,
My task is to open an Image Properties page programmatically. Properties page as you get by right clicking on the image and selecting Properties on Context Menu.
I know rundll32.exe can open up printer properties, Is there a similar way or any another?
Thanks
D
|
|
|
|
|
I don't believe there is a simple way of doing it. But you should be able to adapt this[^] to invoke the properties window yourself.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Thanks much! I will give it a try!
D
|
|
|
|
|
I was testing BackgroundWorker and ran into this problem.
<br />
BackgroundWorker bw = new BackgroundWorker();<br />
<br />
bw.DoWork += new DoWorkEventHandler(bw_DoWork);<br />
bw.RunWorkerAsync();<br />
<br />
void bw_DoWork(object sender, DoWorkEventArgs e)<br />
{<br />
Form3 f = new Form3();
f.Show();<br />
}<br />
The Form f, is unresponsive. How can this problem be solved?
Using this code though, the form runs fine.
<br />
void bw_DoWork(object sender, DoWorkEventArgs e)<br />
{<br />
Application.Run(new Form3()); <br />
}<br />
Thanks.
The next great innovation - A built-in coffee maker in your computer table.
|
|
|
|
|
void bw_DoWork(object sender, DoWorkEventArgs e)
{
Form3 = new Form3();
f.Show();
Application.Run(); //Begins running a standard application
//message loop on the current thread, without a form.
}
This explains, why the form was unresponsive. The messages were not handled at all. With a Message loop, the form works fine.
Any more ideas ?? Maybe there's a better way to do this??
Thanks.
|
|
|
|
|
It won't work because the form is cut off from the application message pump by the thread boundry. In order for the form to work, it has to be on the same thread as the message pump. The message pump is created by the Application.Run() method. It's NOT a good idea to run multiple pumps inside the same app to get around that limitation. UI elements should stay on the main thread.
|
|
|
|
|
Hi Dave, thanks for the info.
So, the appropriate thing to do would be do would be:
- do all the main processing in DoWork function
- Send the required information to displayed by UI via. ProgressChanged or RunWorkerCompleted; unlike what i did by creating a Form or any other control inside the thread
- The UI controls stay in the main thread in this way.
Thanks.
Laex
|
|
|
|
|
How can we implement the Reflection concept in C# Application?
---
Regards
ilango gandhi
|
|
|
|
|
By writing C# code that utilizes the classes in the System.Reflection namespace.
Paul Marfleet
|
|
|
|
|
Hi,
Here you have some Reflection Samples
Visit my blog at http://dotnetforeveryone.blogspot.com
|
|
|
|
|
I did this in VB and would like to do this in C# now.
UserForm1.Controls("chkbx_ManProp_" & CStr(j)).Value = True
any ideas how to convert this to C# in a windows form application?
Thanks
|
|
|
|
|
Crazy VB code, so you want to access the property of a control on another form?
If so, add a method to the forms class that will modify the control. Then you can call the method.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
I wrote the VB app in a short amount of time, so that snippet was pretty much done on the fly ;o
the property of the control(s) that I want to access is within the same form.
Unfortunately, there isn't a direct correlation of VB and C# methods so I'm not sure where to look.
I was thinking about something like this:
start a loop
Application.getControlbyName("object_name_as_string" & integer_variable).value = false
integer_variable++;
end loop
in essance what this should do is programmatically loop through all the controls with similar naming conventions, and set its member value to false.
Any suggestions / alternate ideas on how to accomplish this in c#???
Thanks in advance
Humble.
|
|
|
|
|
ControlName.PropertyName = NewValue;
Not sure why you want to loop through the control list when the above template should work within the same form.
Of course, you could do the looping but it takes a bit more skill and would look something like the code below. I would stick with The Undefeated's advice.
public static Control FindControl(Control root, string nameToFind)
{
Control retval = null;
foreach (Control c in root.Controls)
{
if (c.Name == NameToFind)
{
retval = c;
break;
}
retval = FindControl(c, nameToFind);
if (retval != null)
{
break;
}
}
return retval;
}
|
|
|
|
|
Heh. Agreed that it's easier just to assign a value to a control.
However, I've got 20 controls that need to be assigned the same value.
I declared the control names with the express notion that I would be able to loop through all of them and assign with the same value.
I guess I can modularize it and put it in a method, but I'm slightly surprised I"m not able to do what I could do with VBA code!
:P
|
|
|
|
|
That is because it is inefficient. There is little reason to loop through all controls everytime you want to update a specific one.
VB tends to save lines of code not cpu cycles.
|
|
|
|
|
Hi,
do any one know if
ConnectedClientSocket.Send is sending while we are working on Server
On Client application, through Begin Send and Receive (async calls), it's not getting any data.
What could be the reason? any solution?
thanks
Determination and faith are the only keys !
|
|
|
|
|
I'm programming in C# but I thought this would be a VB question
i'm not sure how to do this, but assume I've got a text box that has a properties.
The properties dynamically change throughout the program, upon request, is there a method through system way to get the text box (or any checkbox, radio button group, label etc.) to change back to its original state?
|
|
|
|
|
No. The controls do not keep a record of their initial state are application startup.
You have to write a method that will reset all the properties of a control to a state that you want. Call this method when you want to reset the textbox.
|
|
|
|
|
Hi,
alternatively you can hide the original Control, then call an "init" method, which
clones the Control, adds it to its parents.Controls and makes it visible.
When you want the original back, remove the Clone, and call "init" again.
So it is always a clone that is shown, gets modified, and the original is never touched.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Though I've never had to reset controls back to a known state, (I tend to destroy and create entire forms instead) that's a trick I'll have to put in the bag.
|
|
|
|
|
I made sure my bag of tricks is an ArrayList, so it accepts all kinds of objects,
and is only limited by total amount of memory available.
Come to think of it, it more resembles a Heap, difficult to enumerate...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|