|
Do you want to trigger the visibility from a another usercontrol?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Dino2Dino wrote: I have a control that I hide in my win forms
How are you accomplishing this?? By overlay another control over the top of this one?
Dino2Dino wrote: Control.visible still returns true
This just means that the control should be repainting itself. It does not determine if the control can actually be seen or not.
|
|
|
|
|
[I MOVED THIS MESSAGE TO THE WPF FORUM: link[^]
Hi!
After searches on google and the built in help of visual studio, I tried to get an answer on this question in the MSDN forum, but nobody seems to answer there. I hope i get better results here!
Here's my (slightly edited) post i posted on the MSDN forum:
Hi,
I'd like to make a List<int> property in a custom control, and, when I add that custom control to the main window of the application, want to be able to edit, add and remove elements from that list. The problem is that I can't edit the items in the designer.
I did the following:
1. Create a WPF application
2. Add a Custom Control (WPF)
3. Changed the code in the CustomControl1 class to the following:
public class CustomControl1 : Control
{
static CustomControl1()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadata(typeof(CustomControl1)));
}
private List<int> _intlist = new List<int>();
public List<int> intlist
{
get { return _intlist; }
set { _intlist = value; }
}
}
} </int></int></int>
4. Added the namespace to the XAML file of the Window1.xaml from the main WPF application
xmlns:CustCtrl1NameSpace="clr-namespace:WpfApplication3"
5. Added the control to the Grid
<Grid>
<CustCtrl1NameSpace:CustomControl1/>
</Grid>
After i did this, i expected to be able to see and edit the List<int> intlist in the designer, but i can only see it. If i click on the button with the three dots on it on the intlist property in the designer, I get the window to edit it, but everything is grayed out!
I really tried alot of things, and i ran out of ideas now.
Hope you can help me,
Vincent
modified on Friday, October 31, 2008 2:37 PM
|
|
|
|
|
vincentgr wrote: I tried to get an answer on this question in the MSDN forum
You have a WPF question and posted it in MSDN forum?
vincentgr wrote: I hope i get better results here!
You have a WPF question and posted it in C# forum?
Try this in WPF forum.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
hehe i meant the MSDN > Forums Home > .NET Development > Windows Presentation Foundation (WPF).
I'm really sorry i posted it in the c# forum! i didn't spot the wpf forum, and thought it would be part of the c# . I"m immediately going to post it there now. Thanks for giving me the tip
Vincent
|
|
|
|
|
Good Luck
While (true) { Human.isLearnable = true; }
|
|
|
|
|
I am trying to create a program to listen to SNMP traps send out by a device randomly and quite frequently.
I am a newbie to network programming. I found out that i have to create an asyncronous connection to the port and then listen to the packet using an event handler. My problem is that my current program only listens to one trap and then stops listening. i have to call it again to start listening again.
------ ----------------------------------My Main program-------------------------------------------------------
SocketAsyncEventArgs e = new SocketAsyncEventArgs();
IPEndPoint Ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 162);
EndPoint Remote = (EndPoint)(sender);
Qumax_Socket.Bind(Ipep);
bool Event_Connect = false;
e.SetBuffer(data,0,200);
e.RemoteEndPoint = Remote;
e.AcceptSocket = Qumax_Socket;
Qumax_Socket.ConnectAsync(e); //CONNECTS ASYNCRONOUSLY
e.Completed += new EventHandler<socketasynceventargs>(this.e_Completed); //EVENT HANDLER FOR TRAP RECIEVE
Qumax_Socket.ReceiveAsync(e); //ACTIVATE RECIEVE TRAPS
------ ----------------------------------My Recieve handler---------------------------------------------------------
void e_Completed (object sender, SocketAsyncEventArgs e)
{
////Code to recieve handler..Deleted for now.////
Qumax_Socket.ReceiveAsync(e); //Call recieve handler again.
}
So looking at my recieve handler i need to call the receeve traps again to listen to more than one trap. If "Qumax_Socket.ReceiveAsync(e);" line is missing the program recieves to one trap and stops.
My worry is that there is a time interval between receiving of the first trap and calling the receieve function again during which a trap send by the remote machine would be missed. This time delay is equal to the code in the recieve handler.Is this something to worry about?
Is there a better way to do this with .NET sockets?
Please let me know.
Thanks
|
|
|
|
|
I found the solution to my problem..The answer is that as long as there is a connection between the port and the reciever, the packets never get lost..they sit in a queue until my reciever handler recieves it
|
|
|
|
|
I am trying to find an existing control or find out how to make a custom one that allows me to have either a listbox or treeview on the left instead of a tabstrip at the top. This is how it is done in both the VS2008 Options and Word 2007 Options and I really like it, but after searching all morning I haven't really made any progress. I have started writing custom controls to try and combine a treeview with a tabcontrol, but haven't made much progress. So, I will just start with this: Does anyone know of a tabcontrol that will show the tabs in a list or tree?
Thanks in advance
|
|
|
|
|
I don't know if there's an existing one but you can simply use a SplitContainer, in the left side add a TreeView, in the right side add some Panels and in NodeMouseClick event call related Panel.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Thanks for replying. I have considered this, but feel that working with multiple layered panels in the designer is messy at best and it just feels like there must be a better solution. Since posting the question I have tried what I want to do in WPF and it is very easy so I may just go with that, but if anyone has any other ideas, I would be glad to hear them.
|
|
|
|
|
aalex675 wrote: feel that working with multiple layered panels in the designer is messy
Agreed, but sounds messy or not, you have Controls (Buttons, TextBoxes, etc.) and you have to add them in your Form in anyway.
aalex675 wrote: if anyone has any other ideas
Add the Controls in Run-Time.
While (true) { Human.isLearnable = true; }
|
|
|
|
|
I'm trying to check the status (open/close) of different files handled by my application. Is there an object containing this information tht I can access with a foreach or something similar?
TiA
---Dirk Bock
|
|
|
|
|
There is no class that holds a list of all your open file-pointers that I'm aware of. You could add a list to your application, and update this list each time you open/close a file.
|
|
|
|
|
If you want to know whether a specific file is open or not you can use this: Deleting Locked Files[^] It's written in c++ but you can use P/Invoke
|
|
|
|
|
Sorry this maybe in the category of esoteric ..but has anyone ever developed an application that connects to merchantconnect to download reports. If so what is the website address.
I ran around in circles till I threw up trying to get hold of anyone in the dev team @ merchantconnect.
|
|
|
|
|
sameerhanda wrote: ever developed an application that connects to merchantconnect to download reports.
Nope. Cannot help you, but wish you good luck in the matter.
sameerhanda wrote: I ran around in circles till I threw up trying to get hold of anyone in the dev team @ merchantconnect.
Thanks a million for the visual
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi,
As I am populating a listbox, the scrollbar moves up and so I do not see the items being added because the scroll keeps on moving to the top...
How do I see the items as they are being added? I guess somehow I would like the scrollbar to stay at the bottom of the listbox?
Thanks
|
|
|
|
|
arkiboys wrote: I guess somehow I would like the scrollbar to stay at the bottom of the listbox?
Why would you want that? Just to 'see' what items the computer is adding? It will slow down the entire operation if you scroll down each time you add an item. It's not just 'scrolling', it's also painting an item, updating an index etc.
I couldn't see a property like "EnsureVisible", but you could try the VB-approach and do a SendKeys.
|
|
|
|
|
Hi,
lb.Items.Add(message);
lb.TopIndex=lb.Items.Count-1;
is the easiest way I found to keep seeing the new lines.
I typically add a condition to the scrolling, such as
if (Controls.ModifierKeys!=Keys.Control)...
so I can actually browse the LB while the app continues throwing text at me.
BTW: if you list the strings upside-down (by inserting at position zero),
you get it for free.
|
|
|
|
|
This is what I am doing to use threading to populate a listbox.
Question:
Do you know how I can write to the text of the winform? i.e. this.text fails
//Thread...
private System.Threading.Thread t = null;
delegate void AddToListDel(string text);
private void AddToListbox(string text)
{
if (this.lstProfileInsertStatusError.InvokeRequired)
{
AddToListDel a = new AddToListDel(AddToListbox);
this.lstProfileInsertStatusError.Invoke(a, new object[] { text });
}
else
{
this.lstProfileInsertStatusError.Items.Add(text);
}
}
private void myButton_click()
{
t = new System.Threading.Thread(new System.Threading.ThreadStart(this.GetProfileElementsValues));
t.Start();
}
private void GetProfileElementsValues()
{
//this line works
AddToListbox("START TIME : " + DateTime.Now.ToShortTimeString());
//this line fails
this.text = "processing " + i;
}
Any thoughts on how to solve this issue please?
I believe I need to have something similar to AddToListbox(string text) but for the text of the form?
Thank you
|
|
|
|
|
Yup, you're not allowed to modify the variables of other threads without locking. Imagine you and me as a thread. You own a car (that's one of your variables). Obviously, we can't drive at the same time. That's why you get an error; I'm not allowed to start steering, without asking you first.
|
|
|
|
|
You can only access the controls from the thread that created them, i.e the main thread.
There are basically two ways of doing that:
1. Use Invoke to make the main thread execute the code, just like you do in the AddToListbox method. If you know that you are always doing that from a background thread, you don't have to check the InvikeRequired property, but just invoke the code directly.
2. Put the data in a synchronised variable (use the lock keyword to synchronise both when reading and writing), where the main thread can look for it and put it in the control.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
What you need to do is add a check if an invoke is required change the text from the main thread by invoking it. To do an invoke you need to do 3 things:
1. Create an EventHandler.
private delegate void SetTextValueHandler(string value);
2. Create a function whose signature matches the delegate and does what you want.
private void SetTextValueToConsole(string value)
{
this.text = value;
}
3. Change the line that fails to something like this:
if(this.InvokeRequired)
{
this.Invoke(new SetTextValueHandler(SetTextValueToConsole), new object[1] { "processing " + i.ToString()});
}
else
{
this.text = "processing " + i.ToString();
}
|
|
|
|
|