1.1 datagrid Column Styles
I am trying to change the column styles i na datagrid, ive been over
exampel after example and cannot seem to figure it out. I am however
quite close the following code works but the datagrid onyl displays one
column in the datagrid and its the last one that had a column style
applied to it
'make table style for the datagrid
Dim tst As New DataGridTableStyle
tst.MappingName = dsInspections.Tables(3).TableName
tst.BackColor = Color.OldLace
tst.AlternatingBackColor = Color.OldLace
tst.HeaderBackColor = Color.Wheat
tst.HeaderForeColor = Color.SaddleBrown
'add column styles for each column
Dim col1 As DataGridColumnStyle = New DataGridTextBoxColumn
col1.MappingName = "ID"
col1.Width = 50
tst.GridColumnStyles.Add(col1)
Dim col2 As DataGridColumnStyle = New DataGridTextBoxColumn
col1.MappingName = "Item"
col1.Width = 100
tst.GridColumnStyles.Add(col2)
Dim col3 As DataGridColumnStyle = New DataGridTextBoxColumn
col1.MappingName = "Description"
col1.Width = 220
tst.GridColumnStyles.Add(col3)
Dim col4 As DataGridColumnStyle = New DataGridTextBoxColumn
col1.MappingName = "Quantity"
col1.HeaderText = "QTY"
col1.Width = 220
tst.GridColumnStyles.Add(col4)
'add table style to the datagrid
dgMods.TableStyles.Add(tst)
dgMods.Refresh() Tag: q; DirectoryInfo.Exists Tag: 104979
How to create a TreeView node with no image?
Hi,
I have a TreeView with an associted imagelist. I want some nodes to have no
icon. How do I do this? How can I create an "empty icon"?
--
Thanks in advance,
Juan Dent, M.Sc. Tag: q; DirectoryInfo.Exists Tag: 104978
.NET 2.0 Webbrowser control
I am using a Webbrowser control in a Windows form application. I need
to be able to read the server variables values. This is very simple in
web apps (request.servervariables()) but i am unable to do so using the
webbrowser control. Am i missing something or is it not possible with
the Webbrowser control.
I would very much appreciate any help in this matter
Thanks
MB Tag: q; DirectoryInfo.Exists Tag: 104977
HWND - What can I do with it?
I am working on extending an NSIS installer and I want to use .NET
windows forms controls within it, can I create a .NET control on the
NSIS parent form with just the HWND of the parent form?
For example, I want to create a .NET listview on a form in NSIS, is
this possible?
I am pretty ignorant as to the capabilities of the Windows API for
things like this and would appreciate any comments or help you could
offer.
Thanks! Tag: q; DirectoryInfo.Exists Tag: 104973
custom gridviw column
Please help, easily reproduced:
1. Create a class inheriting from
System.Windows.Forms.DataGridViewTextBoxColumn .
2. Add a simple property to that class (see below for the code I used).
3. Add a column of that type to a DataGridView.
4. Try to set the property you just created using the "Edit Columns" dialog
at design time.
5. Close and reopen the dialog. The value is gone!
Am i doing something wrong? Setting the value in code works.
Thanks for any help.
Here's the class i used:
Public Class MyColumn
Inherits System.Windows.Forms.DataGridViewTextBoxColumn
Private _MyProperty As String
<System.ComponentModel.Category("MyProperties")> _
Public Property MyProperty() As String
Get
Return _MyProperty
End Get
Set(ByVal value As String)
_MyProperty = value
End Set
End Property
End Class Tag: q; DirectoryInfo.Exists Tag: 104969
BackgroundWorkerProcess and GUI updates (progress windows)
Hi,
I'm writing a little application that scans a large number of media
files for processing.
The main application currently uses a backgroundworkerprocess to
perform the scan. Each media file has meta data extracted and is added
to one of a range of lists (pseudo-queues) for later processing. This
is all fine. But, I want to provide more feedback to the end user as to
progress as the process takes a considerable time.
To do so I have implemented a new modal dialog which outputs counts on
queues, and the current location in the filesystem that the scanning
has reached.
However, I have problems with this.
Firstly, I tried creating the new progress window in the main form
class, that then failed as when I tried to update the labels and
controls on the progress window I could not as the window was created
in another thread.
Then, I tried to create the progress window within the method that the
backgroundworkerprocess thread runs. This did not allow me to create a
modal dialog as I could not pass "this" into the constructor, because
the variable was not created in the same process.
I don't really want to move the logic into the progress window, because
I need to deal with the queues when populated.
This is just all seeming to be too much of a mess. Updating a progress
window is such a COMMON thing that applications do all the time. There
/must/ be a tried and tested pattern for doing so, I can't beleive that
.NET doesn't have a nice simple way to do this.
However, I've failed to find it so far. I'm new to .NET and winforms.
I've done some limited GUI programming in Delphi and a tiny bit in VB6,
I'm primarily an enterprise web application developer. i.e. I can code
well in the web paradigm, but my thick client gui stuff is almost
completely non-extant.
Any pointers to RTFM greatly accepted.
(Oh, .NET 2.0 in C# Express 2005)
Cheers,
Mike Tag: q; DirectoryInfo.Exists Tag: 104968
PAE at WindowsXP64edition.
Dear all
I think Windows64edition has a limitation of 2G memory for each software.
WindowsXP has 4G memory limitation problem and 2G limitation of each software.
I have 2 WindowsXP 64edition computers. One has 8G memory. Another one has
12G memory.
Even if I am using such big memory machine, "memory Out" shows me on a screen.
I have used boot .ini file on WindowsXP, and get PAE.
Is there anyone who knows how to expand the 2G memory for each software???
Akihiko Japan Tag: q; DirectoryInfo.Exists Tag: 104964
Font size based on the client rectangle of the control.
Hi,
I have a control that render text. This is done in OnPaint()
override by drawing the text. When the control is resized, the text
inside it should also be resized according to the size of the control.
Either height of the text or width of the text or both need to be
resized. So I need to determine the font size based on the current
client rectangle. How do I do this? Is there any other way of resizing
the text?
I am using .Net 2.0. Your help is highly appreciated.
Thanks in Advance.
Regards
Kiran Tag: q; DirectoryInfo.Exists Tag: 104962
Howto create semi-modal popup form in MDI application
I'm creating an MDI application in C# 2.0.
I need to show a popup form (similar to a dialog) on an MDI child form, such
that the popup form is modal to the MDI child form, but without blocking
other MDI child forms and obviously without blocking the main application.
I know that I can't use Form.ShowDialog() as it disables all windows on the
thread, but I'm hoping there's a way to simulate the desired behavior. The
popup form has to be associated or parented to the MDI child form so that the
user can switch between the open child forms. More than one MDI child form
can show a popup form at the same time.
Hope someone out the has a suggestion...
Regards
Henrik Rasmussen Tag: q; DirectoryInfo.Exists Tag: 104950
Windows Forms Disabled Text
Hi,
I'm trying to modify the tabCrontrol so I can enable/disable tabs. I've
got it all working except it doesn't look like I want it to.
When a tab is disabled I want the text to look like a disabled button's
text (indented grey?).
Is there a simple way to do this (is there a "disabled" font??) or do I
have to overlay the grey text over the top of the white??
Thanks
Gareth Tag: q; DirectoryInfo.Exists Tag: 104949
Minimized Forms won't restore
Hi,
I have a Windows Forms App, written in c# in VS2005 Professional.
The application requires the user to log on, and after a period of
inactivity they are automatically logged off. The Logon is done on a
seperate form, which then shows the main form.
The application requires 1024 x 768 resolution (due to graphics), and so
if the screen resolution is set to that it runs with no borders / title
bars etc. Otherwise it runs normally in a window.
I have a problem, in that if the user minimizes the main form, then when
they are logged out due to inactivity, the logon form becomes shown
minimized.
The problem comes when the user then wants to display that form in order
to log back on. If the app is running full screen (no title bar etc.)
then it will not restore and remains firmly fixed to the task bar.
Has anyone seen this problem before and is there a solution?
Thanks.
Paul Tag: q; DirectoryInfo.Exists Tag: 104948
Adding a UserControl to the Component Tray
I have a base UserControl class - DataModule - to which I have added a
SqlConnection and a DataSet. The idea is that users will build on this
base class, adding their own SqlCommands as needed, but always using
the same connection/dataset (i.e. a simple API). The reason for using a
UserControl, is to allow users to drag-and-drop SqlCommands etc. from
the Toolbox directly onto the design area; they can then select those
objects from the Component Tray and edit their properties.
These subclasses of DataModule will then be placed onto another
UserControl containing a DataGridView, and the user will connect the
DataModule's DataSet to the grid's DataSource. So far, I've got the
above working great.
However, when I drop a DataModule subclass onto a UserControl, the
DataModule is placed on that UserControl's canvas. Because DataModule
itself isn't meant to be used as a visual component, it makes more
sense for it to appear in the Component Tray instead; however, I can't
seem to get this to work. (I've tried the DesignTimeVisible attribute,
as well as others.)
>From what I've read, it seems that any component that's a subclass of
Control cannot be displayed in the Component Tray. Is this correct, and
if so, is there any way to work around this?
Also, if you think this implementation is incorrect, please tell me!
(I am using .NET 2.0 with Visual Studio 2005 Professional.)
TIA. Tag: q; DirectoryInfo.Exists Tag: 104946
How can I control positioning of child windows in an MDI form?
Hello
I have a question about CHILD forms in an MDI form.
How can I have a neat positioning of child windows in an MDI form?
When I open a new child window in my MDI form it is opened in a new
cascading position but when I opens a lot of forms, it goes out of the
borders of the MDI form and a scroll bar appears in the MDI form.
Is there a neat positioning of child windows in an MDI form?
Any help (or link) is appreciated.
Hamed Tag: q; DirectoryInfo.Exists Tag: 104942
MDI Form Position
Hello
Two questions about positioning:
When I run my MDI application developed by VS.NET 2003, the MDI window is
opened in a new place and after some run again and again, it opens in a
position that some borders of MDI form goes out of the desktop.
The WindowState of MDI form is in Normal state.
Q1: How can I open my form in a position that the form is not gone out of
desktop
Q2: How can I position in the same position as previously opened in the last
run.
Thanks in advance.
Hamed Tag: q; DirectoryInfo.Exists Tag: 104941
How to suppress new-data row in datagrid with parent-child data
Hi All,
I have a form set up with a data source which has a parent-child
relationship. The parent table is bound to a combo box, and the child
to a datagrid. I want the datagrid to show the child records for the
parent selected in the combo. I know how to do this, and it all works
fine. But I cannot suppress the datagrid row with the * against it,
where a new row can be entered.
>From what I have read, the way to do this is to make the data source
for the datagrid a DataView, with the AllowAddNew property set False.
That's fine, but as soon as I do that I lose the parent-child behaviour
- catch 22!
Is there a way to suppress the new-data row in the grid, AND preserve
the parent-child behaviour I need? It sure as hell isn't intuitive! Tag: q; DirectoryInfo.Exists Tag: 104940
FileDialog (SaveFileDialog & OpenFileDialog) does not add extension
I use FileDialog's quite often, but this one thing really bothers me:
The FileDialog.AddExtension property is supposed to control whether the
extension of the selected filter is automatically appended to the
filename or not, also depending on the CheckFileExists property
(according to
http://msdn2.microsoft.com/en-us/library/system.windows.forms.filedialog.addextension.aspx).
However, with FileDialog.AddExtension set to true and regardless of the
state of FileDialog.CheckFileExists propetry, the extension is NOT
appended to the filename. Can someone please help me why this is?
(For information, I used the filter "C-Sharp Files|*.cs|Text
Files|*.txt|All Files|*.*" and DefaultExtension "cs" if it makes any
difference) Tag: q; DirectoryInfo.Exists Tag: 104932
Form.TopMost behaviour
I'm a bit confused regarding the behaviour when setting the Form.TopMost
property. If setting the property to 'true', does it make the form top-most
of all windows in all applications, or only the form's application ?
Searching google, I've found people claiming it's enough to set TopMost in
order for the form to be top-most of all windows in the system, and other say
that a call to Win API's SetWindowPos (with HWND_TOPMOST as a parameter) is
needed.
So, which is correct? Tag: q; DirectoryInfo.Exists Tag: 104928
how to show a form or process command line args
Hello. I would like to write a console application and windows form
application all in one. If there are command line arguments, then I would
treat it as a console app. Otherwise, I would display a form. I'm having
trouble doing this. Any ideas??
Here's what I did so far:
1) Create a new console application
2) In the Main, i use this code, but it only briefly displays the form, then
it goes away. The code looks like this:
Sub Main(ByVal args() As String)
If args.Length = 0 Then
Dim frm As New frmMain
frm.Show()
frm.Focus()
Else
'....
End If
End Sub
Thank you in advance for your response!
Steve Tag: q; DirectoryInfo.Exists Tag: 104925
Consuming JavaScript events fired in AxWebBrowser control
I have an AxWebBrowser control in a C# app. I'd like to have my C# app
capture, say, an OnClick event of an HTML element in the AxWebBrowser
document.
Is this possible?
TIA
Jared Tag: q; DirectoryInfo.Exists Tag: 104923
Changing default header/footer when printing from AxWebBrowser
I've wrapped the web browser control in a user control, and I'm able to
print using the execCommand("Print") method. However, this puts "Page
X of Y" in the header, and "about:blank" and the date in the footer.
How can I override the default header and footers?
TIA
Jared Tag: q; DirectoryInfo.Exists Tag: 104922
Validating a DataGridViewComboBoxCell on focus lost
Hi, i would like to make a DataGridViewComboBoxCell (which often is the
last-edited one) validate in such a way that when the datagrid lost the
focus the ComboBox cell Text property is setted to the combobox Value
property. I've already written all the code needed to change the
ComboBox view from a only-pushbutton style to a combobox style (with
the text box editable i mean) and to add the Text value to the ComboBox
Items and then setting the Value property of the ComboBox to the
original Text value. But all works correctly only if i change the
focus from the ComboBox cell to another cell. Instead if i click a
button outside the DataGridView the cell is not validated and so the
Value is not setted and remains null.
Is there a way to cause the validation of the DataGridView (and of the
ComboBox cell as well) when the DataGridView lost focus?
thanks Tag: q; DirectoryInfo.Exists Tag: 104921
BeginInvoke and user-interaction
I have a datagrid whose datasource is being updated by a function started by
BeginInvoke.
If the user (as the datagrid is being populated) drags the scrollbar (or
even clicks it and doesn't release
the mouse-button) the datagrid-population is being stopped.
When the user release the mouse-button the datagrid-population is continued.
I would like the population of the datagrid to continue while the user drags
the scrollbar.
Is it possible and how can I achive this?
Thanks Tag: q; DirectoryInfo.Exists Tag: 104915
What causes exception in ComboBox
When selecting last item in combobox I receive the following exception in VS:
System.ArgumentOutOfRangeException was unhandled
Message="InvalidArgument=Value of '31' is not valid for 'index'.
Parameter name: index"
ParamName="index"
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.ComboBox.ObjectCollection.get_Item(Int32 index)
at System.Windows.Forms.ComboBox.UpdateText()
at System.Windows.Forms.ComboBox.WmReflectCommand(Message& m)
at System.Windows.Forms.ComboBox.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.UnsafeNativeMethods.SendMessage(HandleRef
hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam,
IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd,
Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.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.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.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.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
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 FAST.AppMain.Main(String[] args) in
C:\Dev\client_dev_shared_FAST2\FAST_UCM\FAST\client\FASTGUI\FAST
Application\Main.vb:line 25
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()
I dont have any event handlers for the combobox and I'm not catching any
exceptions with the VS debugger. What gives, another bug? Tag: q; DirectoryInfo.Exists Tag: 104914
Windows Forms Stylesheets?
Is there anything equivalent to CSS for use in windows forms? Iâ??d like to be
able to have the colors and fonts determined by some kind of configuration
file (ala Cascading Style Sheets) so that individual application users can
customize the user interface to there taste.
Is there any simple way to accomplish this? If not, does anyone have any
suggestions for methods or strategies to accomplish this?
Oh... by the way, I'm using Visual Studio 2003 & VB.NET but would happily
use Visual Studio 2005 if this functionality was built in.
Thanks,
Jonathan Tag: q; DirectoryInfo.Exists Tag: 104910
datetime
I have a date value in a database and I want to show it's value on a form.
It is bound to the data and shown with a datetimepicker. When the value in
the database is null, an incorect value is shown on the form. is there a
way to get null to show when it is null? Tag: q; DirectoryInfo.Exists Tag: 104901
Display ToolTip on TextBox
(Created on VS2003 using C#)
I have derived the TextBox control to create my own control that does a
lot of filtering and autocorrection of user input. I want to be able to
give feedback to the user when there's a problem the input he's trying
to do. A good example is in Windows XP if you go to windows explorer
and in the folders view try to rename a directory with "\", this will
result in a arrow tooltip to display saying that certain characters are
forbidden.
I was thinking of adding a ToolTop control to my TextBox control (yes I
know it's wasteful, but I could work something so they all use the same
tooltip, that I will work on later). Now in 2003 there's no .Show(...)
method for the ToolTip control, and I don't think my company is gonig
to migrate to 2005 before this week, when I have to release the
software.
Has anyone beem able to show the tooltip programatically without
waiting for the user to do a hover?
Thanks Tag: q; DirectoryInfo.Exists Tag: 104900
Detect if Workstation is locked
Hi,
I want to detect in my C# app (can use iterop) if the workstation is locked.
I've seen on the web people saying it's impossible except by looking if the
Screensaver process is running. There must be a clean way of doing it
because MSN detects it and can change your status based on this.
Does someone have a solution to this please?
thanks
ThunderMusic Tag: q; DirectoryInfo.Exists Tag: 104884
Form - mouse selected
I'm trying to enable my disabled menu options (cut, copy & paste). The
requirement is to determine what on my form has been selected with the mouse.
How can I determine this? Tag: q; DirectoryInfo.Exists Tag: 104877
Forcing DataGridView to repaint a row/disabling a row
I have a datagridview that is bound to a datasource. The under lying
data is not from a database, but biz objects. The first colume (InUse)
is a check box to determine if the rest of the row is enabled. When
the row is not in use, it is grayed out in the CellFormatting event.
After the user checks the InUse colume, the rest of the row does not
get repainted.
Is there a better way to control editablity of individual rows? If
not, how do I go about making the whole row get updated correctly? As
I click on the different cells and leave them, they change to the
correct color. Tag: q; DirectoryInfo.Exists Tag: 104876
outlook 2003 left panel look in c#
Hi
I'm wondering how can i make a control that looks like the left panel
of
outlook 2003 , i'm talking about the low part where you see mail,
calendar,
contacts. this panel you can set the height and the number of 'button'
will
change there is also a configure button to it.
how can i build a control that will look like that using C# 2.0
control, I
know that some 3rd party sell those but i don't want to buy those.
thanks Tag: q; DirectoryInfo.Exists Tag: 104874
ComboBox Binding Problem
I am binding a Collection Business Object to a ComboBox in Visual Basic 2005
in a Windows Form Application. The SelectedValue is then bound to another
Business Object. When I create a new instance of the object I can use the
Combo to look up values but display member is being cleared on losing focus.
DisplayMember, Value Member, etc is set as per documentation and per other
similar threads in newsgroups. Some are reset after component initialised to
be doubly sure they are set. On Editing existing records combo does not
display any value, even though when tested the selected value is correct.
I tested code in same form with Janus Combo and it worked perfectly using
properties displaymember, valuemember and SelectedValue (Using
DataSourceUpdateMode.OnPropertyChanged ).
This would lead me to view I am doing everything correctly but the MS Combo
is not behaving correctly. Can anyone shed any light on this, is there a
bug with the control?
Regards Tag: q; DirectoryInfo.Exists Tag: 104873
TypeDescriptor get Conveter attached to a property
I have class that has a property wich has a custom typeconverter:
class A
{
private string _property;
[TypeConverter(typeof(MyTypeConverter))]
public string Property
{
get { return _property; }
}
}
How can I get an instance of this typeconverter? When I do
A a = new A();
TypeDescriptor.GetConverter(a);
I get an instance of the default Typeconverter attached to the class A
(as expected).
When I do
TypeDescriptor.GetConverter(TypeDescriptor.GetProperties(a)[0].GetValue(a));
I get an instance of the default Typeconverter of the class string (as
expected).
How would I retieve the instance of MyTypeConverter attached to
Property ? Tag: q; DirectoryInfo.Exists Tag: 104872
outlook 2003 left panel in c#
Hi
I'm wondering how can i make a control that looks like the left panel of
outlook 2003 , i'm talking about the low part where you see mail, calendar,
contacts. this panel you can set the height and the number of 'button' will
change there is also a configure button to it.
how can i build a control that will look like that using C# 2.0 control, I
know that some 3rd party sell those but i don't want to buy those.
thanks Tag: q; DirectoryInfo.Exists Tag: 104869
Custom Control with Transparent Background
/*
How can I give my custom System.Windows.Forms.Control a transparent
background? In the small application below, I expect to see two partially
overlapping circles, a blue one and a red one, but only the blue circle
appears. When the background of the controls iis transparent, both circles
will show.
If this feature is not available or only through some kind of hack, what is
the reason that Microsoft does not support controls with transparent
background?
*/
using System.Drawing;
using System.Windows.Forms;
//class ColorCircleControl
class ColorCircleControl:Control
{
//data member brush
Brush brush;
//data members x,y
int x;
int y;
//constructor
public ColorCircleControl(Brush a,int b,int c)
{
brush=a;
x=b;
y=c;
SetStyle(ControlStyles.SupportsTransparentBackColor,true);
BackColor=Color.Transparent;
Dock=DockStyle.Fill;
Paint+=OnPaint;
}
//OnPaint
void OnPaint(object a,PaintEventArgs b)
{
b.Graphics.FillEllipse(brush,x,y,55,55);
}
}
//class MyForm
class MyForm:Form
{
//constructor
public MyForm()
{
Controls.Add(new ColorCircleControl(Brushes.Blue,34,55));
Controls.Add(new ColorCircleControl(Brushes.Red,55,55));
ClientSize=new System.Drawing.Size(233,144);
}
//Main
[System.STAThread]
static void Main()
{
System.Windows.Forms.Application.Run(new MyForm());
}
} Tag: q; DirectoryInfo.Exists Tag: 104868
GDI objects count
Hello all,
Can somebody help me out regarding how to maintain the GDI objects
count in my application it keeps on incrementing and once reaches to
10000 the application dies. Can somebody point to me some sample
application which could help me to understand how exactly manage the
object disposal I have been reading the articles for memory management
and GC but things are getting more and more confused to me.
Needed help urgently
Thanks in advance Tag: q; DirectoryInfo.Exists Tag: 104866
The good old Cross-thread operation not valid
Hi,
Does anyone know if there is a better solution for the good old
"Cross-thread operation not valid" than dealing with delegates and
Invokes? (This happens when you access GUI from a thread that did not
create it)
I realize that the problem is based on the old Windows requirement
(only thread that created the window shalt process its messages) but it
is 21 century and the new VS 2005 was supposed to be all about
productivity, concentrate on your buisness logic and do not write
plumbing code etc... If poluting your code with delegates and Invokes
just to do (txtBox1.Text = "Blah") is not plumbing I am not sure what
is....
Anyway, does anyone know if a better, more straightforward solution
exist? I guess the anonimous methods help a bit but it is still pretty
ugly. I also read about the BackgroudWorker component but that one is
not very intuitive either...
Ivan Tag: q; DirectoryInfo.Exists Tag: 104858
Performance of form controls refreshing on Resize
Hi, I'm a little new to forms programming with C#, so I'd appreciate
some pointers on how I can improve the (perceived) performance of my
form when it's resized.
My form contains a TabControl, which has a couple panels, about 15 text
boxes + labels, and two comboboxes, all bound to a custom object. When
I resize the form, the controls on the form seem to resize/repaint very
slowly. I had thought there's a way to hide this repainting of each
control, to make the overall operation appear faster, but I'm not sure
where to handle that.
Thanks for any pointers,
Michael Tag: q; DirectoryInfo.Exists Tag: 104856
Tracing not allowed in installed winforms application
I have tracing set up in my application to write out to a log file.
Now If I install the application from my setup project and try to run
it, I am getting an exception that says something along the lines of:
"UnauthorizedAccessException: ... Access to the path
...\myAppLogFile.log is denied"
I checked the permissions of the directory inside of program files and
sure enough, only administrators were allowed to Modify the files in
the directory. I was logged in as a non-administrator when I was
testing. When logged in as adminstrator, no problems arise.
Does anyone know of a good approach to this? Perhaps I should modify
the directory permissions on install?
Thanks,
Jonathan Tag: q; DirectoryInfo.Exists Tag: 104850
Crystal Reports 'Logon failed' error
I have read all the postings in this forum for this dreaded unpopular error,
but I haven't found a resolution to my problem yet and I really need to get
this bug resolved. I have a winforms app written in VS 2002 which contains a
number of Crystal Reports, all of which were working fine. I had to change
the data source of 1 report from Stored Procedure A to Stored Procedure B in
my SQL Server 2000 db. Connections are made through ODBC, not integrated
security. I was able to do this without difficulty by resetting the Location
of the report source, but when I try to open the report at run-time, the
following occurs:
- prompt appears asking for db password. server name, db name, and username
are prefilled.
- when correct password entered, 'Logon Failed' message appears
- when correct password entered a second time, login box disappears and
report displays
I am logging on in code every time I load any Crystal Report, and none of the
others give me this prompt. All reports are loaded into the same report
viewer on the same page; I just have a long select case statement which
indicates which report to load. I would really appreciate any help you could
offer. Here is the complete code:
Sub PrintReport(ByVal strRpt As String, ByVal strSp As String, ByVal
ParamArray paramValues() As Object)
'Prints selected Crystal Report
'Params: 1. Name of report to print
'2. Stored Procedure to run
'3. Array of Paramater names & values
Dim objRpt As Object
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Dim crLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo()
Dim objData As New BusinessRules.CDataAccess()
Try
'1. Create selected report object
Select Case strRpt
Case "rptcarrierform"
objRpt = New rptcarrierform()
Case "rptInvoice"
objRpt = New rptInvoice()
Case "rptInvoiceCharges"
objRpt = New rptInvoiceCharges()
Case "rptCreatedInvoices"
objRpt = New rptCreatedInvoices()
If Not IsNothing(objFrm) Then
objFrm.Close()
End If
Case "rptNoInvoice"
objRpt = New rptNoInvoice()
Case "rptWSIB"
objRpt = New rptWSIB()
Case "rptManifest"
objRpt = New rptManifest()
Case "rptRunningOrder"
objRpt = New rptRunningOrder()
Case "rptBrokerage"
objRpt = New rptBrokerage()
Case "rptBrokerage2"
objRpt = New rptBrokerage2()
Case "rptMedical"
objRpt = New rptMedical()
Case "rptLicense"
objRpt = New rptLicense()
Case "rptAccruals"
objRpt = New rptAccruals()
Case "rptCancelled"
objRpt = New rptCancelled()
Case "rptInvoice2"
objRpt = New rptInvoice2()
End Select
'2. Connect to db
rptViewer.LogOnInfo = New CrystalDecisions.Shared.TableLogOnInfos
()
crLogonInfo.TableName = strSp & ";1"
objData.ReportLogin()
With crLogonInfo.ConnectionInfo
.ServerName = objData.ServerName
.DatabaseName = objData.DatabaseName
.UserID = objData.UserID
.Password = objData.Password
End With
rptViewer.LogOnInfo.Add(crLogonInfo)
'3. Add Report Parameters
SetParameters(paramValues)
'4. Bind data and display report
rptViewer.ReportSource = objRpt
rptViewer.Show()
Catch objError As Exception
CException.LogError(objError)
End Try
Me.Cursor.Current = Cursors.Default
End Sub
Private Sub SetParameters(ByVal ParamArray parameterValues() As Object)
Dim ParameterFields As CrystalDecisions.Shared.ParameterFields
Dim ParameterField As CrystalDecisions.Shared.ParameterField
Dim spValue As CrystalDecisions.Shared.ParameterDiscreteValue
Dim p As SqlParameter
Try
If Not parameterValues Is Nothing AndAlso parameterValues.Length
> 0 Then
ParameterFields = New CrystalDecisions.Shared.ParameterFields
()
For Each p In parameterValues
If (Not p Is Nothing) Then
ParameterField = New CrystalDecisions.Shared.
ParameterField()
spValue = New CrystalDecisions.Shared.
ParameterDiscreteValue()
' Check for derived output value with no value
assigned
If (p.Direction = ParameterDirection.InputOutput
OrElse p.Direction = ParameterDirection.Input) AndAlso p.Value Is Nothing
Then
spValue.Value = "NULL" 'DBNull.Value
End If
'Set parameter name & value
ParameterField.ParameterFieldName = p.ParameterName
spValue.Value = p.Value
'Add to parameter collection
ParameterField.CurrentValues.Add(spValue)
ParameterFields.Add(ParameterField)
End If
Next p
'Add parameter collection to Report Viewer
rptViewer.ParameterFieldInfo = ParameterFields
End If
Catch objError As Exception
CException.LogError(objError)
End Try
End Sub
--
Message posted via http://www.dotnetmonster.com Tag: q; DirectoryInfo.Exists Tag: 104847
return value
I had this working and now it's not. I call one form from another then I
return a value to the first. I had a public sub in the parent form that the
child would call and set the variable. The value in the parent form always
ends up 0 now. Even though it appears the value the child is sending is
correct. As soon as the child form closes the value resets to zero. I'm
not sure why it was working before and now is not. Can anyone explain my
error? Tag: q; DirectoryInfo.Exists Tag: 104846
get form
Hi
I have a windows application. This application opens some forms. I wold like
to get the first form (the one includes main) from the other forms and call
some functions in that form. How do I do this? I know
Thanks
Julia Tag: q; DirectoryInfo.Exists Tag: 104845
DataBinding to DataGridView AND TextBoxes?
Hi,
My problem:
When the cursor is on a given row in the DataGridView, the data in the row
has to be shown in TextBoxes underneath the DataGridView. the user must be
able to edit in the Datagridview, or in the textboxes. The text in these
textboxes and the datagridview has to be synchronsied at all time. So if the
user types "a" in the Name-Column, the "a" has to appear immediately in the
Textbox etc.
This doesn't seem to be as easy as I thought. I used a BindingSource, and I
handle the EditingControlShowing_TextChanged-event of my DataGridView, and
in that handler I force commits after each keypress
(Me.dgvArticles.CommitEdit(DataGridViewDataErrorContexts.Commit) ) and do a
ResetCurrentItem of my BindingSource. But this doesn't work always, not when
it's the first time a suer selects a row etc etc etc...
So: a lot of trouble, and still not the desired result.
Does anybody knows how to do this? I would help me really a lot!
Thanks a lot in advance,
Pieter Tag: q; DirectoryInfo.Exists Tag: 104839
Making sure special characters display correctly
I will admit it up front, ever since some version of DOS went global, I've
gotten a headache everytime I even contemplated codepages:-)
I want to be able to display three special characters, in one case as the
password character, and in the other cases as the text on a small button in a
datagridview.
I've scanned over the postings and the recommended KB articles and if I
wanted to do a web page in Korean or process a document around in Hebrew, i
think i could do it. What I can't do is make the some simple code work:-(((
Essentially all I coded was
textbox.passwordchar = "â?º" ' character is a smiley
My stupidity was selecting a font for the dialog that did not have â?º in it.
(Verdana) Yet. it worked fine at the office. Out at the client site i got a
square box instead. I solved the problem by making sure all the relevant
controls used Arial even if the rest of the dialog was using Verdana.
So I have questions to help me understand what is going on.
My client is using XP in a Detroit suburb so there is nothing fancy going
on. What settings for the OS should I look at to see why it worked at the
office but not at their site? (Charmap for shows the stuff of interest just
fine. A test console app at their site shows the characters of interest just
fine. It's the windows app that has problems.)
I just repeated the exercise here at the office. With the font of the
textbox defaulting to verdana 9 pt - as confirmed by a msgbox display of the
font name - i get some appropriately scrunched up smiley face as I type. With
the font set at Arial 11 i get a big bold face as I type. QUESTION: What
mechanism is causing Framework to display a character that isn't in the font,
i.e. the scrunched smiley when the font is set to Verdana?
It gets even weirder. With the font set to verdana, i turned the password
character off (there is a check box for that, something I wish all programs
provided for the mornings we aren't typing quite right:-). Then I copied some
Hebrew off charmap and pasted it into the textbox. It worked! I copied â?²â?ºâ?¼â??
and got the phenomenon I'm seeing here. The Up and Down arrows are in one
size and the left and right in a different size. QUESTION: What is going on
here?????
--
Regards,
Al Christoph
Senior Consultant
Three Bears Software, LLC
just right software @ just right prices @ 3bears.biz
Microsoft Certified Partner (ISV)
Coming soon: Windows Mail tools for Vista. Tag: q; DirectoryInfo.Exists Tag: 104838
ReportViewer... "the handle is invalid"
Hi all,
Posting this again using my shiny new posting alias (so an MS representative
will respond).
Using the 2.0 framework (no hotfixes) I'm trying to print a report without
previewing it. The code looks like:
public partial class fErrors : Form
{
private DataImportServices.ImportError[] _Errors;
public fErrors()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ImportErrorBindingSource.DataSource = _Errors;
reportViewer1.RefreshReport();
}
private void reportViewer1_RenderingComplete(object sender,
RenderingCompleteEventArgs e)
{
//
// Report finished let the user choose a printer
//
reportViewer1.PrintDialog();
}
}
The report viewer is initialized as follows:
reportDataSource1.Name = "DataImporter_DataImportServices_ImportError";
reportDataSource1.Value = this.ImportErrorBindingSource;
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
this.reportViewer1.LocalReport.ReportEmbeddedResource =
"DataImporter.rErrorsList.rdlc";
this.reportViewer1.Location = new System.Drawing.Point(251, 11);
this.reportViewer1.Name = "reportViewer1";
this.reportViewer1.Size = new System.Drawing.Size(149, 28);
this.reportViewer1.TabIndex = 3;
this.reportViewer1.Visible = false;
this.reportViewer1.RenderingComplete += new
Microsoft.Reporting.WinForms.RenderingCompleteEventHandler(this.reportViewer1_RenderingComplete);
Roughly speaking the report is just a simple listing of errors... a line
number and error message/description (the errors just happen to be returned
by a webservice... but I don't think that is related to the problem).
When I click the print button (button1) I'm prompted with the select printer
dialog, I do not change anything... just click print (I have a default
printer, a Dell 1710n, Adobe PDF, and a fax printer). The processing dialog
appears... and then boom an exception.
The specific exception is:
System.Reflection.TargetInvocationException was unhandled
Message="Exception has been thrown by the target of an invocation."
Source="mscorlib"
StackTrace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target,
Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target,
Object[] arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at
System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry
tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object
obj)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at
System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(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.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
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.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at DataImporter.fMain.cmdImport_Click(Object sender, EventArgs e) in
...\My Documents\Visual Studio
2005\Projects\DataImporter\DataImporter\fMain.cs:line 564
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
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 DataImporter.Program.Main() in ...\My Documents\Visual Studio
2005\Projects\DataImporter\DataImporter\Program.cs:line 21
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()
The inner exception is:
System.ComponentModel.Win32Exception "The handle is invalid",
Error code: -2147467259
Source: System.Drawing
Stack trace:
at
System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument
document, PrintEventArgs e)
at
System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(PrintDocument
document, PrintEventArgs e)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at Microsoft.Reporting.WinForms.ReportViewer.PrintDialog()
at DataImporter.fErrors.reportViewer1_RenderingComplete(Object sender,
RenderingCompleteEventArgs e) in ...\My Documents\Visual Studio
2005\Projects\DataImporter\DataImporter\fErrors.cs:line 80
at
Microsoft.Reporting.WinForms.ReportViewer.OnRenderingCompleteUI(ProcessThreadResult
result, PostRenderArgs postRenderArgs)
and Target site is :
{Void OnStartPrint(System.Drawing.Printing.PrintDocument,
System.Drawing.Printing.PrintEventArgs)}
This exact error condition is also mentioned in the following posts:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541808&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=216364&SiteID=1
http://groups.google.sm/group/RS2005/browse_thread/thread/ac870db0bf8cc3db/548ad83c984f3192?hl=it#548ad83c984f3192
One of the posts seemed to suggest the problem might be printer model
specfic... so I tried printing to the Adobe PDF "printer"... worked like a
charm.
So... is this a known problem with the reportviewer? Is there any
workarounds? Is there anything I can do to help pin the problem down
further?
Regards,
Rob M.
--
rmacfadyen@nospam.nospam Tag: q; DirectoryInfo.Exists Tag: 104836
Get Latest version on startup
Hi,
Anyway to hide the dialog box when getting latest version on project
startup. Tag: q; DirectoryInfo.Exists Tag: 104835
Best Practice from Oracle DB to DataGridView
Hi,
I'm wondering whats the best practice to accomplish the following
display in a DataGridView.
1. Perform a Query to an Oracle DB with a multiple join select that
returns multiple rows. (Should I use a DB object i.e. Stored Procedure,
Function, View, or nothing)
2. Bind the rows/data to a DataGridView via DataAdapter or
DataTable/Set.
What is most people/the best practice for doing the listed? I heard
using ref Cursors but they cause headaches. Is there a practice that
allows me to do everything via the VS2005 IDE?
Thanks in advance.
Newton Tag: q; DirectoryInfo.Exists Tag: 104834
Publishing from a ClickOnce deployment project
How do you publish from a deployment project? I know how to publish from the
solution (right-click select publish and use the publish wizard) but now I
want to do the same steps automatically in a deployment project. If I need
to use a custom action, what do I actually need to do within the custom
action to get the application to publish. Tag: q; DirectoryInfo.Exists Tag: 104826
ComboBox binding to subset of another ComboBox
This is for a Windows Forms application...
I am wanting to set up binding once, if possible, for a second combobox that
contains filtered data based on the first.
I know I can capture the event of the first combobo and then bind the second
based on the value, but was hoping that there is an easier/better way.
Here is the scenario
class Car
{
Guid carID;
int year;
string carName;
}
class Manufacturer
{
Guid id;
string name;
List<Car> cars;
}
class MyCollection
{
List<Manufacturer> makers;
}
private void MyControl_Load( object sender, EventArgs e )
{
cboMaker.DisplayMember = "Name";
cboMaker.ValueMember = "ID";
cboMaker.DataSource = makers;
cboCar.DisplayMember = "CarName";
cboCar.ValueMember = "CarID";
cboCar.DataSource = ??? <<<<<<<<<<<<<<<<
}
Thanks,
Dave Tag: q; DirectoryInfo.Exists Tag: 104818
Tooltip in TreeView control
Hi,
I have a TreeView control in my project (I am working with VS2003, C#).
I also have a tooltip attached to it, which I use to display special
information once user places (MouseMove) the mouse on a TreeNode.
The TreeView control has a basic behaviour that once a TreeNode text
(name) exceeds the size of the control, a tooltip is displaying the
TreeNode text (name). now I have two tooltips showing:
1. treenode text (name).
2. my special information.
My aim is to prevent the first tooltip from showing. I tried to
override WndProc() in the following way:
protected override void WndProc(ref Message m)
{
if(m.Msg == TTN_SHOW)
{
//ignore tooltip show message
return;
}
base.WndProc (ref m);
}
IT DID NOT WORK!
I defined TTN_SHOW to be (found it in commctrl.h):
TTN_FIRST = (0U-520U)
TTN_SHOW = (TTN_FIRST - 1)
Apperantly this is not the message the control receives :(
could somone explain why? Tag: q; DirectoryInfo.Exists Tag: 104816
DirectoryInfo.Exists(myDir) gives an exception if I run the exe though a
mapped drive, what might the problem be?