|
Look, it's extrememly unlikely you're ever going to get an answer to this question, no matter how many times you ask it, simply because of the obscurity of the information you're looking for. There are very few people on the planet that have ever messed around with the old OLE file format of Word.
If you want the file format, you can look at this[^].
|
|
|
|
|
Hi,
When should i use this:
protected virtual void OnEvent_PageMenu_Info(string msg)
{
if (Event_PageMenu_Info != null)
{ Event_PageMenu_Info(msg); }
}
and this:
Event_PageMenu_Info(msg);
Sometimes i use one or the other but dont know why
Thanks
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Assuming Event_PageMenu_Info is an event....
What happens if you raise the event before checking for null and
there's nobody subscribed to the event? NULL reference exception
If you've implemented a OnEvent_PageMenu_Info(), then that should be used
to raise te event.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
He could add a do-nothing event handler inside the class that throws the event so that the invocation list is never empty.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I found a neat trick recently - can't remember where.
You can add a dummy handler when declaring the event:
public event EventHandler<...EventArgs> MyEvent = delegate { };
Then the event is never null .
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
ooooohhhhhh - good tip. That deserves a 5.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Excellent - nice tip Nick - 5'd
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Yeah, as Mark said.
Plus wrapping it in a method allows derived classes to raise the event as well.
|
|
|
|
|
Everything the others have said. Also, Microsoft recommend (and use themselves) a copy to handle the possibility of the event becoming null after the null check but before it's raised. This is the way I implement something like this:
using System;
public class MyPage
{
public event EventHandler<PageMenuInfoChangedEventArgs> PageMenuInfoChanged;
private object _PageMenuInfo;
public object PageMenuInfo
{
get { return _PageMenuInfo; }
set
{
if (_PageMenuInfo != value)
{
_PageMenuInfo = value;
OnPageMenuInfoChanged(new PageMenuInfoChangedEventArgs("Changed!"));
}
}
}
protected virtual void OnPageMenuInfoChanged(PageMenuInfoChangedEventArgs e)
{
EventHandler<PageMenuInfoChangedEventArgs> eh = PageMenuInfoChanged;
if (eh != null)
eh(this, e);
}
}
public class PageMenuInfoChangedEventArgs : EventArgs
{
public PageMenuInfoChangedEventArgs(string message)
{
_Message = message;
}
private string _Message;
public string Message
{
get { return _Message; }
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanks everone for the posts
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
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
|
|
|
|