|
Hi guys, if i loop on the attribute collection i can't get the RangeValidator, a custom class objct.
for(Attribute att in attributes)
{
if (att is RangeValidator)
{
Messagebox.show("RangeValidator");
}
}
but if i do like Attribute am= pd.Attributes[typeof(RangeValidator)]; then i am able to get the RangeValidator a custome attribute
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(_obj, attributes))
{
Attribute am= pd.Attributes[typeof(RangeValidator)];--->how come now i can get the RangeValitor this way
}
}
[RangeValidator(10,20)]
public int foo
{
get{return _foo;}
set{_foo=value;}
}
Thanks
|
|
|
|
|
How to activate last textbox in DataGridView on re-activate ?
I created testcase for it:
1. Run code.
2. Enter some data to grid
3. Click other form caption
4. Click original form caption
5. Enter some characters
Observed: entered characters are ignored
Expected: entered characters must appear in last cell before form activation
How to fix ?
using System.Windows.Forms;
public class Test
{
static void Main()
{
Application.Run(new MainForm());
}
}
class MainForm : Form
{
public MainForm()
{
WindowState = FormWindowState.Maximized;
IsMdiContainer = true;
Form frm = new Childform();
frm.MdiParent = this;
frm.Show();
Form frm2 = new Childform();
frm2.MdiParent = this;
frm2.Show();
frm2.Left = 2000;
}
}
class Childform : Form
{
public Childform()
{
var grid = new DataGridView();
grid.Columns.Add(new DataGridViewTextBoxColumn());
grid.EditMode = DataGridViewEditMode.EditOnEnter;
Controls.Add(grid);
}
}
Andrus
|
|
|
|
|
Hello
I'm getting a Graphics with a transformmatrix
Is it possinle to use the graphics without the transformmatrix (set it to null or whatever)
then set back the original matrix
I've tryed .Reset() but it does not work !
Thanks for your help
|
|
|
|
|
I want to open a child window on a seperate thread, from a parent window. The code in parent window should execute seperately and the code in child window should execute seperately.
I tried it using multithreading but couldn't do it. I was able to execute functions as seperate thread but not entire window.
I hope this can be done.
Errors are like Mini Skirts, shorter they get, more revealing they become.
|
|
|
|
|
Can't be done. All Windows, Forms, Controls must be created and manipulated
by the main thread only; if you need additional threads, they should not
touch the Controls, instead they should use the Control.InvokeRequired/Invoke
pattern to tell the main thread to read or write Control properties and call
Control methods in their behalf.
Anything else is bound to fail, either immediately, or at some later time, with
often mysterious phenomena such as disappearing menu bars, windows "Not
responding" and much more.
|
|
|
|
|
Hi,
I have a tabControl in which I add tabPages like so:
TabPage newPage = new TabPage();
NewOrder newOrd = new NewOrder();
newPage.Controls.Add(newOrd);
tabControl1.Controls.Add(newPage);
My application is resizable and the tabControl has anchors so that it resizes with the app. I'm having problems getting the newOrd to resize as well... it stays as a fixed width within the tabPage. I tried using anchors on these objects but it didnt get them to fit correctly. Now I'm trying to bind the newOrd.Width to the newPage.width, but am unfamiliar with how to bind in .Net
Any help is appreciated.
Thanks!
|
|
|
|
|
Hello:
I have just a rudimentary experience so far with programming but want to make my own app in order to do some things that I cannot find a freeware app that does exactly what I want (plus I just want to create something for fun too!)
To help me get started, I wanted to know if anyone can point me to any code examples, tutorials, or a beginner C# programming book that covers:
(1) the very basics of a photo organizer (like Windows Photo Gallery, Picasa, etc.)
(2) the ability to view image metadata (EXIF, IPTC, XMP)
(3) the ability to edit image metadata (EXIF, IPTC, XMP)
I will be using Visual C# 2008 Express and Windows Vista (and in the future would like to work with Windows Home Server)
Anything that gets me going in the right direction would be immensely helpful, thanks!
modified on Friday, October 31, 2008 3:47 PM
|
|
|
|
|
Im using the FtpWebRequest object to upload a file to an FTP server. The problem is that if a directory that is part of the remote path does not exist, it fails. Otherwise the file is upload with out error with the code below.
I'd almost like to assume that since the request method is UploadFile, that it would create directories as needed. But I must be wrong. So is there be a way to accommodate dynamic creation of the directories?
The Error Message
[System.Net.WebException] = {"The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."}
Here's some code to review if you wish.
The UriBuilder
UriBuilder uB = new UriBuilder();
uB.Scheme = Uri.UriSchemeFtp;
uB.Host = ConfigurationManager.AppSettings["FTPRemoteHost"].ToString();
uB.UserName = ConfigurationManager.AppSettings["FTPRemoteUser"].ToString();
uB.Password = ConfigurationManager.AppSettings["FTPRemotePass"].ToString();
FileInfo uFInfo = new FileInfo(localpdf);
uB.Path = remotepath + uFInfo.Name;
The value of the UriBuider Uri property
{ftp:
The function I'm working with
public bool UploadFile(Uri serverUri, string localFile)
{
if (serverUri.Scheme != Uri.UriSchemeFtp)
return false;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UseBinary = true;
if (File.Exists(localFile) == false)
return false;
StreamReader sourceStream = new StreamReader(localFile);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
if (fileContents.Length <= 0)
return false;
request.ContentLength = fileContents.Length;
try
{
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
return false;
}
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
#if(DEBUG)
WriteEvent(response.StatusDescription, EventLogEntryType.Information);
#endif
response.Close();
request.Close();
return true;
}
Just because we can; does not mean we should.
|
|
|
|
|
hi,
I have a control that I hide in my win forms and Control.visible still returns true, where I want it to be false.
Whats the alternative?
|
|
|
|
|
if its hidden it wouldn't return true, it would return false.
Are you sure you are checking the visible property of the *correct* control?
|
|
|
|
|
Make sure that you are setting visible property of the control to false. Not seeing the control doesn't mean that it's not visible (there might be another control above it)
|
|
|
|
|
Hi,
you can see a Control c if all these conditions have been met:
- c has been added to its parents Controls collection;
- c.Visible=true;
- c.Location is somewhere on the visible Form;
- c is not covered by something else.
So not seeing c does not imply c.Visible is false, there are several reasons
you might not see it.
To add one more: its rendering may be ineffective, e.g. a Label with
ForeColor and BackColor both set to the container's BackColor.
|
|
|
|
|
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
|
|
|
|