|
I like that idea. A regex over a path size string should be blindingly fast as well.
"Once in Africa I lost the corkscrew and we were forced to live off food and water for weeks." - Ernest Hemingway
My New Blog
|
|
|
|
|
Hi All,
Is there any control/method/class/namespace available that i can use in my code in order to get windows XP like left menu.
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
|
That was very helpful.
Thank You!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Hi..
I have a web application(ASP.NET 2.0, C#), in which I am exporting a xml file.
The web page has a button called Export. When the user clicks the Export button, the File Download pops up, in which it has the Open,Save and Cancel Butons as in a normal file download pop-up. Being an xml file, the page also opens up,without the content behind the File download pop-up,
When the user clicks Cancel button, the file download pop up is gone, but the xml page(without the contents) is still open. This also happens when the user has successfully downloaded the xml file(Xml page is open)
Is it possible to close the xml page after the user clicks the cancel button and after the user saves the xml file? I am using Internet Explorer 6, Windows xp, SP1.
Please help.. Thanks
Thanks & Regards,
Venkat
|
|
|
|
|
i want to create a shape Control like that you got here. But his Control can t draw antialiased linies =/
How can i draw smooth linies ?
|
|
|
|
|
If I recall theres some settings on the Graphics object that can help you out. Anti-aliasing is more of a quality setting on the Graphics object, than specifically asking for the thing you are drawing to be smoothed.
|
|
|
|
|
Yea i use this already but it looks not really Antialiased =/
the edges of a pie, for example, looks fuzzy but not smoothed
I have a Custom Control wich inherits from the Control class and my paint code looks like this
protected override void OnPaint( PaintEventArgs e ) {
base.OnPaint( e );
if( ( this.Width <= 0 ) || ( this.Height <= 0 ) ) return;
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath path = createGraphicPath( Shapes.Pie);
this.Region = new Region( path );
Pen pen = new Pen( new SolidBrush( borderColor_ ), borderWidth_ );
pen.DashStyle = borderStyle_;
e.Graphics.DrawPath( pen, path );
path.Dispose();
pen.Dispose();
}
|
|
|
|
|
Runtime error on accessing "role" from App.config file.
Any idea how to fix the problem?
Code:
string str = System.Configuration.ConfigurationManager.AppSettings["role"];
App.config:
<configuration>
<appsettings>
<add key="role" value="Easy">
<policyinjection>
<policies>
<add name="Policy">
Thanks
|
|
|
|
|
You will need to re-post since you forgot to check the "Ignore HTML tags in this message" check box. So we can't see your app.config or your error message.
Thanks,
Ben
|
|
|
|
|
Oops but i figured out the problem. Thanks anyway.
|
|
|
|
|
I need WinForms function which displays modal window with text given as parameter and returns value entered by user or null if esc pressed.
Where to find some source code for this ?
Andrus
|
|
|
|
|
Form f = new Form();
f.ShowDialog();
myValue = f.formValue.ToString();
If you look at the above, create a new form replacing the "Form" with the name of your form.
Show the form with a ShowDialog() will prevent any other part of your app from showing till the form is closed.
Then access a public variable or accessor of your form to set a local variable to the value the user entered.
Hope this helps you.
Hogan
|
|
|
|
|
Hi
How to insert string value and Button in Datagridview cell.
Like properties window in visual studio 2005.
In our project, their is a module which shows same like Properties windows in visualstudio 2005. so that we use datagridview and using DataGridViewComboBoxCell to insert combo box in some particular cell.
our problem is suppose if we insert a filename, so that we need textbox and same with small button which will used to browse the file.
so that how to insert usercontrol or textbox with button in datagridview cell?
|
|
|
|
|
i didn't work a lot With DataGridView, adding userControl to DataGridView can be done but in the cell I don't know
you can inherit from DataGridViewTextBoxCell class and override the Paint method for resizing the TextBox (i said form TextBoxCell because creating a TextBox is far more harder than a Button) and for drawing a button beside the textBox.
I know this is a tedious solution but it would work!
|
|
|
|
|
Thanks Hessam Jalali, yet to try this, can you explain little bit briefly.
|
|
|
|
|
I need to add row in DatagridView based on array of business entities.
I'm using NHibernate.
NHiberante returns array of business objects.
So my source type is System.Array and I cannot change it.
Joe Stegman "DataBinding FAQ - Updated.doc" describes that BindingList<t>
AddingNew event should be used in this case.
Also there is CoreAddNew method which is not documented in VCS 2005 Express
documentation.
I expect that BindingList<t> or some of its implementation can maintain
separate list of added objects by implementing custom Add() method.
How to fix ?
Andrus.
Using .NET 2.
Code to reproduce:
using System.Windows.Forms;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
<br />
class TestApplication {<br />
static void Main() { Application.Run(new TestForm()); }<br />
}<br />
<br />
class TestForm : Form {<br />
<br />
DataGridView DataGridView = new DataGridView();<br />
<br />
public TestForm() {<br />
Controls.Add(DataGridView);<br />
<br />
BindingSource BindingSource = new BindingSource();<br />
IList<Customer> list = new Customer[0];<br />
BindingList<Customer> bindingList = new BindingList<Customer>(list);<br />
BindingSource.DataSource = bindingList;<br />
<br />
BindingSource.AddingNew += delegate(object sender, AddingNewEventArgs e) {<br />
e.NewObject = new Customer();<br />
};<br />
<br />
DataGridView.DataSource = BindingSource;<br />
}<br />
}<br />
<br />
class Customer {<br />
string name;<br />
public string Name {<br />
get { return name; }<br />
set { name = value; }<br />
}<br />
}
Observed:
System.NotSupportedException was unhandled
Message="Collection is read-only."
Source="mscorlib"
StackTrace:
at System.ThrowHelper.ThrowNotSupportedException(ExceptionResource
resource)
at
System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object
value)
at System.Windows.Forms.BindingSource.Add(Object value)
at System.Windows.Forms.BindingSource.AddNew()
at System.Windows.Forms.CurrencyManager.AddNew()
at
System.Windows.Forms.DataGridView.DataGridViewDataConnection.AddNew()
at
System.Windows.Forms.DataGridView.DataGridViewDataConnection.OnNewRowNeeded()
at System.Windows.Forms.DataGridView.OnRowEnter(DataGridViewCell&
dataGridViewCell, Int32 columnIndex, Int32 rowIndex, Boolean
canCreateNewRow, Boolean validationFailureOccurred)
at System.Windows.Forms.DataGridView.SetCurrentCellAddressCore(Int32
columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean
validateCurrentCell, Boolean throughMouseClick)
at
System.Windows.Forms.DataGridView.SetAndSelectCurrentCellAddress(Int32
columnIndex, Int32 rowIndex, Boolean setAnchorCellAddress, Boolean
validateCurrentCell, Boolean throughMouseClick, Boolean clearSelection,
Boolean forceCurrentCellSelection)
at
System.Windows.Forms.DataGridView.MakeFirstDisplayedCellCurrentCell(Boolean
includeNewRow)
at System.Windows.Forms.DataGridView.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
at
System.Windows.Forms.ContainerControl.AssignActiveControlInternal(Control
value)
at
System.Windows.Forms.ContainerControl.ActivateControlInternal(Control
control, Boolean originator)
at
System.Windows.Forms.ContainerControl.SetActiveControlInternal(Control
value)
at System.Windows.Forms.ContainerControl.SetActiveControl(Control
ctl)
at System.Windows.Forms.ContainerControl.set_ActiveControl(Control
value)
at System.Windows.Forms.Control.Select(Boolean directed, Boolean
forward)
at System.Windows.Forms.Control.SelectNextControl(Control ctl,
Boolean forward, Boolean tabStopOnly, Boolean nested, Boolean wrap)
at System.Windows.Forms.Control.SelectNextControlInternal(Control
ctl, Boolean forward, Boolean tabStopOnly, Boolean nested, Boolean wrap)
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TestApplication.Main() in C:\test\test\Program.cs:line 20
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
*/
Andrus
|
|
|
|
|
Good evening!
I would like to add OnClick-events to all button-controls within a form which contains a single split-container. I'll try to explain it:
I have a Windows form which includes one control, a spli-container, which itself has two panels. In one of these there are several buttons. All of them should subscribe to a click-event during initialization process.
I tried it with
[code]
foreach (Control in this.Controls)
{
if (cntr is Button)
{cntr.Click += new EventHandler(delegate(object sender, EventArgs e) {MessageBox.Show(cntr.Name);});}
}
[/code]
but "this.Controls" contains only the split-container.
I know that in this very special example I could as well enumerate through the panels of the split-container, but I would like to use a solution which is independent of the amount of the panels.
I think a possibility is needed, which allows to check if a control contains sub-controls and if so, one of these is a button type control.
Help would be appriciated!
|
|
|
|
|
you can use recursive method (as deep first search or stack search)
it would be somewhat like this
void AssociateClick(Control starterControl)
{
if(starterControl==null)return;
foreach(Control c in starterControl.Controls)
{
if(c is Button)
c.Click+=new EventHandler(c_Click);
AssociateClick(c);
}
}
void c_Click(object sender, EventArgs e)
{
MessageBox.Show((sender as Button).Name);
}
if you pass the form as starter it would iterate in all controls and if iterated control is a button the c_Click method would be associated to that
and of course it can be implemented with other methods like Breadth search (with Q) but maybe recursive is the easiest way in this case
hope the post would be useful
good luck
|
|
|
|
|
Thank you! Works like a charm. Now as I see it it seems logical.
|
|
|
|
|
Hi,
Iam trying to open a word document using filestream and thereby put the data in byte array by reading the filestream.
Now, i want to write back the byte stream to a file like doc file, would there be any complexities by doing this?
If the document has some images can it be written back to a file?
code is as follows:
//for reading
FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate,
FileAccess.Read);
long len;
len = fileStream.Length;
Byte[] fileAsByte = new Byte[len];
fileStream.Read(fileAsByte, 0, fileAsByte.Length);
same logic for writing too
Thanks,
gauthee
|
|
|
|
|
Hi,
you can read all bytes of all files you can access.
and you can write these bytes again to any location you can access.
Since .NET 2.0 you can do it with File.ReadAllBytes and File.WriteAllBytes,
you don't need streams for that.
Don't really know what good it all will do for you tho. You probably will
not be able to understand the bytes, nor change them in any way that
results in a valid new document. And you can't just convert a document
by changing its file extension, if that were what you hope for.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi All,
I have got a problem in events. I have a treeview Before_Select event and one is Panel_leave event
so when i m on panel and i click a treenode the Panel_leave is executed but Before_Select doesn't execute .But if i make a break point in Panel_leave it works and if i remove break points it doesn't work.
Please help in solving this problem , I think i need thread Synchronization , but i don't know how to do it.
Thanx.
Praveen Sharma
|
|
|
|
|
Hi,
the events go to the active message pump, that is the GUI trhead of the
currently active window (which normally means: the main thread for all windows).
So Panel_leave and Before_Select normally get handled by the same thread,
that will not be the problem.
Are you sure Before_Select does not fire? How did you figure that?
Best way is: add log statements such as log("begin of Before_Select");
and provide a log method in every interested class, e.g.
public static void log(string s) {
s=DateTime.Now.ToString("hh:mm:ss.fff")+" "+s;
Console.WriteLine(s);
}
If however you try to manipulate some controls from inside another thread,
then you must use Control.InvokeRequired property and Control.Invoke() method;
if not, all kinds of strange things may and will happen.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi!
I have something like this:
public class MyApp: System.Windows.Application
{
public MyApp()
{
m_Window = new Window();
}
Window m_Window;
}
and it gets instantiated from:
class Program
{
[STAThread]
static void Main()
{
MyApp app = new MyApp();
app.Run();
}
}
Every time someone says m_Window.Close() the whole application gets terminated ( = also 'app' gets terminated).
But that is not what I want, I want only to close m_Window ( = 'app' should keep running).
So, where did I go wrong?
Thanks,
Mario M.
|
|
|
|
|