HitTestInfo Returning Wrong Column
I've been working with the hittestinfo class in my application trying to
determine what column my user has clicked. Everything works fine so long as
the columns are set to their default 75 pixel width. When I change the width
of the column either in my columnstyle or in the datagrid control at
runtime, the incorrect column is being returned.
here's the code...
Dim tempGrid as DataGrid = DirectCast(sender, DataGrid)
'--- Select the whole row when the user clicks in the cell area ---'
Dim pt as New Point(e.X, e.Y)
Dim ht as DataGrid.HitTestInfo = Me.grdPoItems.HiTest(pt)
If ((ht.Row > -1) AndAlso (ht.Column > -1)) Then
MessageBox.Show(cstr(ht.Column))
End If
I have this placed inside a DataGrid.MouseUp event handler.
I'm working with VS 2003, Framework 1.1, No SP's installed.
Has anyone else seen this behavior?
jim Tag: DataGrid Scrollbar problem Tag: 60765
Extending "Save As" Dialog
My question is:
How can i extend the "Save As" Dialog. For example if i
am working in Word and i want to save my document in my
new app, i want to select "save as" and i want my app to
be shown in the options.
I hope to be clear.
Thanks. Tag: DataGrid Scrollbar problem Tag: 60758
printer share name
i am held up.. please help me
i have installed one network printer on my system and
through c# program i want to get the share name of that
printer.. the printer is installed on another machine and
is shared.. can anybody help me? Tag: DataGrid Scrollbar problem Tag: 60757
Form.Container property
Hello,
When I put components on a form the designer appears to package them up
nicely in a container component.
Does the inherited System.Windows.Forms.Form read-only Container property
give access to these components?
If not, how can I access a form's component list given only a reference to
the form "As Form" ?
Thanks for any help
Jon Tag: DataGrid Scrollbar problem Tag: 60756
Removing Excel.exe from memory
This seems to be a topic that has been discussed at length in newsgroups,
but I still can't get it to behave...
I'm using automation to get at an existing Excel spreadsheet and then
retrieve data from it. I then want to close down the Excel process. What
I'm getting though, is the process remaining in memory until my app shuts
down.
I am, by the way, aware that MS article 257819 is a better method of getting
at the data, but sadly the spreadsheets that I'm working with are created by
another piece of software and they're just not quite right. The ADO
approach doesn't work with them.
My code (referencing MS article 317109 and numerous newsgroup postings) -
just a sample to simply open Excel and the file, and then to shut it
down....the form will need a reference to the Excel object library.....
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Open the file
Dim file As String = "c:\data\vs\test.xls"
Cursor.Current = Cursors.WaitCursor
Dim objExcel As Excel.Application
Dim Books As Excel.Workbooks
Dim Book As Excel.Workbook
Dim Sheet As Excel.Worksheet
objExcel = New Excel.Application()
Books = objExcel.Workbooks
Book = Books.Open(file)
Sheet = Book.Worksheets(1)
Sheet.Unprotect()
'...and then attempt to close it
Dim objEachWorkSheet As Excel.Worksheet
Dim objEachWorkBook As Excel.Workbook
For Each objEachWorkBook In objExcel.Workbooks
For Each objEachWorkSheet In objEachWorkBook.Worksheets
NAR(CObj(objEachWorkSheet))
Next
objEachWorkBook.Close(False)
NAR(CObj(objEachWorkBook))
Next
NAR(objExcel.Workbooks)
objExcel.Quit()
NAR(CObj(objExcel))
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
Cursor.Current = Cursors.Default
End Sub
Private Sub NAR(ByVal o As Object)
Try
Dim i As Integer
Do
i = System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
Loop While i > 0
Catch excpUnexpected As Exception
MsgBox(excpUnexpected.ToString())
Finally
o = Nothing
End Try
End Sub
Anyone have a method of putting the Excel process out of it's misery?
--
For real reply address, lose the cash
www.realuk.co.uk Tag: DataGrid Scrollbar problem Tag: 60755
center the font in a tab control?
Hi there,
is there any possibility to center the titles in a tabcontrol object?
Normaly the font is alligned to the left hand side by default.
THX Tag: DataGrid Scrollbar problem Tag: 60753
How to determine average character width for a font?
Does anyone know how to determine what the average width of a character is
for a font?
The reason I want to know is that I want to use it to size my text boxes.
For example, if I know that a text box will always accept 8 characters, I
want to size the text box so that it is roughly the size that will display 8
characters.
Jon Tag: DataGrid Scrollbar problem Tag: 60745
Setting permissions for limited user accounts
Hi All,
I have two questions related to permissions which is going to cause me to
lose my last piece of hair on top of my head. I am using VS2003 on XP Pro
with Framework 1.1
1. The windows app creates registry keys during the install. However, when
users with limited rights access the application it raises the Access to
registry key is denied error. The user can go into these registry keys by
using regedit. Besides, while executing these code lines, the assembly
requests the registry access rights by using System.Security.Permissions.
Well, it doesn't work unless the admin goes to registry and right clicks on
the associated registry key to give full permission to the machine users. If
this is my only option, then how can I do this programmaticaly?
2. Setup places a folder and several files for shared access from this
folder. This folder also needs to grant access to users. How can I do this
programmaticaly?
Thank you very much for your help.
Korhan Tag: DataGrid Scrollbar problem Tag: 60742
Problem with Form.BindContext().Position
I have a form with a DataGrid with AllowSorting property
sets true.
I am usually using the form.DataBinding
(DataSet,DataMember).Position as the index when I need get
the match data from the DataSet, but when I click on the
header column to sort the rows, the Position porperty is
changed to a value different from index.
The question is, how can I get the corret row in dataset
using the Form.BindingContext's properties with the
DataGrid's AllowSorting set True?
Best regards,
Mauricio (Brazil) Tag: DataGrid Scrollbar problem Tag: 60725
Is this a datagrid/combo bug???
Hi
I have a form with a combo and a datagrid
The combo has these properties:
Datasource: DataSet11.tPersoner
Displaymember: ChristianName
It does not have any databindings
The datagrid has these properties:
Dim dv As DataView = DataSet11.tPersoner.DefaultView
DataGrid1.DataSource = dv
Because I want different bindingmanagers for the two controls.
Now when I change the current cell in the datagrid (by clicking with the
mouse) they are not synchronized (which I don´t want them to be). But if I
sort the datagrid by clicking on a column header suddenly the combo shows
the ChristianName of an (appearantly random) row in the datagrid.
(I have created two different CurrencyManagers for the controls. And they
are not synchronized. their .Position are not the same)
It seems strange to me.
Any explanations?
best regards
Jan Tag: DataGrid Scrollbar problem Tag: 60722
Control size BUG! URGENT
Hi there,
I think I found a critical bug in Studio .net 2003.
Try this,
Create a Form.
Create a Panel within the Form.
Create a Button within the Panel.
Now set the Button's Location.Y property to a value that it becomes above
the panel's visible area, for example, set Location.Y to -300. Now run the
program, close it again and then check Button's Size.Height value. It is now
bigger one pixel than before. It also happens if you do the same thing to
Location.X property.
Can you tell me how to correct this bug? I tried to create a component that
implements IExtenderProvider to change control's height to less one pixel
everytime it goes to designmode but I can't find a event that is raised when
this happens.
I need this because I want to create a visual control like the
Explorer-style tab that you can found on the left side of a folder browsing
window. All controls inside the tab come from above, so I have to set the
Anchor property to (Left or Bottom).
It's very important for me, please reply as soon as possible.
Thanks,
Filipe Freire Tag: DataGrid Scrollbar problem Tag: 60721
Can't reference control(s) outside groupbox
I can't access any properties of controls outside a
groupbox when handling events of controls belonging to
this groupbox.
Any suggestions? Tag: DataGrid Scrollbar problem Tag: 60720
'System.NullReferenceException' not breaking in MDI ChildForm
I am developing some forms that use multiple accessors to
get information from within user created controls.
MainForm is Parent
JobForm is a MDI child
It has a user Control called MaterialControl
Eg.
MaterialControl has an accessor JobinProgress
Which Accesses a Job Class, which in Turn Access a
Materials class which in Turn accesses the AddMaterial
Method
Eg:
JobinProcess.Job.Materials.AddMaterial
JobinProcess has accessor to Job
Job has an accessor to Materials
Materials has the Actual Method.
My problem is when I do not have something initialized
properly during development and one of these accessors
contains a null value.
During debugging it just drops out of the MDi child Form
being processed and breaks in the Parent form where the
the MDI child form is being created, with
the 'System.NullReferenceException' showing in the Main
MDI Parent Form as opposed to staying in the MDI child
Form with an error on the line generating the error.
This requires me stepping through the code line by line
to figure out which line is generating the error so I can
fix it.
Do I have something wrong in my debugging setup. It
seems like it is only in the case of an null in an
accessor that it does this. All other times it breaks
into the code where the error is as opposed to dropping
me out of the child form.
Any help or nudges in the right direction would be
appreciated. Tag: DataGrid Scrollbar problem Tag: 60717
Custom Control's Properties in Design Time
I've got a custom control that I'm working on which has a
property that is somewhat analogous to the DockPadding
property in other controls (ALL, left, right, top, bottom).
I've put together a type converter that returns the
correct information with one exception: when I change the
all property, I'd like the property grid to display the
value for the rest, as does the DockPadding property.
When I select the individual values, they change the
display, but I much rather have them change automatically
upon modification of the all property.
Thanks,
-Dan Tag: DataGrid Scrollbar problem Tag: 60716
datagrid - word wrap text in column
I am looking for a way to display all of the text in a
column without having the user actually tab into the
column or having the column width be really huge.
I have a readonly datagrid in a windows form and I would
like the comments field to word wrap. I have changed the
row height and the column width, but the user still has to
tab or click in the column to see all of the text.
I have tried setting the DataGridTextBoxColumn style to
wordwrap - but I think that this only works if the column
is being edited. (the datagrid is never allowed to be
editied)
Any help would be appricated.
darkd Tag: DataGrid Scrollbar problem Tag: 60712
DataTable.AcceptChanges causes form to be first in z-order
I have a C# windows forms application with a form which
opens a
non-modal form containing a data grid. The datagrid's
datasource is a
DataTable. If the datatable's AcceptChanges method is
called, the
non-modal form is moved to the front in Z-order. Is there
a way to
prevent this? I have tried setting the datagrid's
dataSource to null,
before calling AcceptChanges as well as calling BeginInit
and
BeginLoadData before AcceptChanges, but with no success.
I have also noted that setting the DataSource on the
DataGrid to null will also cause the Z-order issue.
Any ideas for work arounds?
The sample code is included:
Form1 contains 2 buttons. One to open the non-modal Form2
and one to
call a public method on Form2 which calls Form2's data
table's
AcceptChanges method.
Form2 contains a simple data grid with a datatable with
one column and
one row.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after
InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
} base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer
(this.components);
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler
(this.timer1_Tick);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(48,
80);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(168, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "textBox1";
//
// button1
//
this.button1.Location = new System.Drawing.Point(32,
184);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 56);
this.button1.TabIndex = 1;
this.button1.Text = "Show DataGrid Form";
this.button1.Click += new System.EventHandler
(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(144,
184);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(72, 56);
this.button2.TabIndex = 2;
this.button2.Text = "Data Table Accept Changes";
this.button2.Click += new System.EventHandler
(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void timer1_Tick(object sender, System.EventArgs
e)
{
System.Diagnostics.Trace.WriteLine("Form
Focused="+this.Focused.ToString()+"
TBfocused="+textBox1.Focused.ToString());
}
private Form2 m_Frm2;
private void button1_Click(object sender,
System.EventArgs e)
{
if (m_Frm2==null || m_Frm2.Visible==false)
{
m_Frm2 = new Form2();
m_Frm2.Show();
}
}
private void button2_Click(object sender,
System.EventArgs e)
{
if (m_Frm2!=null)
m_Frm2.DataTableAcceptChanges();
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form2.
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private DataTable m_DataTable;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components =
null;
public Form2()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
m_DataTable = new DataTable("MyTable");
m_DataTable.Columns.Add("Col");
m_DataTable.Rows.Add(new string[] {"A"});
dataGrid1.DataSource = m_DataTable;
}
public void DataTableAcceptChanges()
{
m_DataTable.AcceptChanges();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
} base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)
(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(72,
40);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(408, 216);
this.dataGrid1.TabIndex = 0;
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(632, 365);
this.Controls.Add(this.dataGrid1);
this.Name = "Form2";
this.Text = "Form2";
((System.ComponentModel.ISupportInitialize)
(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
} #endregion
}
} Tag: DataGrid Scrollbar problem Tag: 60710
Showing a form on another form's load
Hello.
How can I show a form as modal on another form's load
event so that the calling form is shown before the called
form.
I tried it by calling Form.ShowDialog from inside another
form load event, but the called form is shown before the
calling form gets visible.
Any ideia?
Thanks in advance,
Celio C. J. Tag: DataGrid Scrollbar problem Tag: 60704
Highlighting in the TreeView
Hi!
In my treeView it seems possible to Select a Node
via SelectedNove, because the treeView is scrolling
to that position (althoug it's not in the middle)
But it isn't hightligthing it as if i would click
it with the mouse.
how do i do this ?
thanks for help,
nick Tag: DataGrid Scrollbar problem Tag: 60703
Excel text import wizard
I'm in the process of writing a text import wizard and would like to base
the 'preview' portion on the one Excel uses; a kind of grid/edit control
hybrid... has anybody come across a component that would offer similar
functionality?
tia Tag: DataGrid Scrollbar problem Tag: 60702
Active title bar font
Hi,
I'm writing a windows forms application in C# and I need to know active
title bar font type and size. Any opinions how to obtain it in the code?
Thanks
JP Tag: DataGrid Scrollbar problem Tag: 60701
Using axWebBrowser
Hello,
Using axWebBrowser control, how do I make it to always open a link in a new
browser window?
thanks,
/m Tag: DataGrid Scrollbar problem Tag: 60697
How to authenticate users?
Hi all,
I would like to write a Windows application who manage his own users and
roles.
The app should be able to create user, give roles to users, ...
Any users will be prompted for a username and password and affected by given
roles to this user.
Depending on the roles of the authorized user, the app authorized some
window and block some others!
(ex : if it's the admin how is connected all task must be done, but if it's
a guest user only the display product list will be accessible, other tasks
not show or disabled!)
I have some experience in web develloppement but none in windows app :-(
Is it possible to do that with a database! or use something like
authentication model with ASP.Net ???
Any idea or help is welcome.
In advance I thank you for your attention.
Regards.
MD Tag: DataGrid Scrollbar problem Tag: 60696
Weird problem, startup form is not brought to front.
Hi All,
I have a problem where my startup form is not brought to form.
First I have a splash screen while the application is loading. In the
startup method I call
Application.Run(new Form1()); // This is the main form
and then inside Form1 I call
SplashScreen.Close() // to close the splash screen
The splash screen is displayed, but the Form1 is hidden behind the windows
explorer where I start up the application. This is odd, does anyone has any
suggestion?
Thanks,
/m Tag: DataGrid Scrollbar problem Tag: 60695
How to show one-to-many relation in 2 DataGrids?
Let's say I have three database tables, each one having 2 columns:
DOCUMENTS contains columns "DOC_ID" (autonumbered) and "Name" (string)
DOCU_KEY contains columns "DOC_ID" and "KEY_ID" (both indexed)
KEYWORDS contains KEY_ID (autonumbered) and "Keyword" (string)
It is set up this way to be able to assign multiple keywords to each
document, and to keep the database normalised.
Now I would like to display two DataGrids, one displaying a list of
documents, a second one displaying the keywords that have been assigned to
those documents. I would also like to be able to insert (using the '*' row)
documents in the first DataGrid, and to insert keywords in the second
DataGrid.
When a keyword is used for the very first time, a new record should be added
to the KEYWORDS table. The next time, a record will be added to the DOCU_KEY
table, the KEYWORDS table remaining untouched.
While I could do this very easily by having only two tables (Documents and
Keywords) by using a DataRelation, and using that relation as a source for
the second DataGrid (by specifying DataMember="Documents.KeywordRel"), I
can't figure out how to do it with three tables. I guess there's a
straightforward solution, since even the most simple normalised database
contains this kind of setup over and over...
Or should I keep writing lots of application code?
Any suggestions?
Is there a good book explaining this kind of stuff?
TIA,
Luc K Tag: DataGrid Scrollbar problem Tag: 60692
DataGrid Merging row
How can I merging the rows in my DataGrid in Windows Form?
I'm looking for something like Webform's RowSpam or like MergeRow
FlexGrid's propriety.
Thank you
Marco Tag: DataGrid Scrollbar problem Tag: 60691
WindowsFormsParkingWindow
Hi,
I've written an application in C# and the application freeze sometimes. This
happens when I changed the language in full screen mode (without border and
main menu)
When this happened and I use the alt-tab combination then I see a .Net icon
with the name WindowsFormsParkingWindow.
Any idea?
Thanks in advance.
Gaby Tag: DataGrid Scrollbar problem Tag: 60684
Undo on InternetExplorer
I am still trying to get the Undo function work on Internet Explorer editor
hosted as activex in my c# application.
Some time ago I've found a note at msdn that says "undo is not supported". I
gave up.
But lately I've downloaded LutzRoeder Writer that makes use of undo
function. I've looked at the code and it turns out that it uses
IOleCommandTarget interface to invoke this command.
Because I cannot get it to work, I have questions:
1. is it a good way to follow? the undo does not work when invoked by
execCommand on IHtmlDocument. is there a chance that it will work with
IOleCommandTarget then?
2. after few days of fighting, digging through msdn and the groups archive,
I've came up with following code but it still does not work. when asking for
CanUndo I always get 0.
could anyone share his/her experiences with me and tell me where the problem
could be? I can send the full source code of my webbrowser control if
needed.
thanks in advance,
Wiktor Zychla
----------------------------------------------------------------------------
---
public class MyWebBrowser
{
// the rest of the code is not here
public enum MiscCommandTarget
{
Find = 1, ViewSource = 2, Options = 3, Undo = 43
}
internal int GetCommandInfo( MiscCommandTarget commandId )
{
OLECMD[] ole = new OLECMD[1];
ole[0] = new OLECMD();
ole[0].cmdID = (int)commandId;
OLECMDTEXT ret = new OLECMDTEXT();
((IOleCommandTarget)Document).QueryStatus( ref cmdGuid, 1, ole, ret );
return ( (int)ole[0].cmdf >> 1 );
}
internal bool IsEnabled( MiscCommandTarget commandId )
{
return ( (this.GetCommandInfo( commandId ) & 1) != 0);
}
internal object Execute( MiscCommandTarget command )
{
return this.Execute( command, null );
}
internal object Execute( MiscCommandTarget command, object[] arguments )
{
object[] array = new object[1];
int n = ((IOleCommandTarget)Document).Exec( ref cmdGuid, (int)command,
2, ref arguments, ref array );
if ( n != 0 )
{
MessageBox.Show( string.Concat( "Execution of MSHTML command ID '",
command, "' failed.") );
}
return array[0];
}
public bool CanUndo
{
get
{
return this.IsEnabled(MiscCommandTarget.Undo);
}
}
public void Undo()
{
if ( this.CanUndo ) this.Execute( MiscCommandTarget.Undo );
}
}
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public int cmdID;
public int cmdf;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct OLECMDTEXT
{
public int cmdtextf;
public int cwActual;
private int cwBuf;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]
public string text;
}
[ComImport, Guid("b722bccb-4e68-101b-a2bc-00aa00404770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleCommandTarget
{
[PreserveSig()]
int QueryStatus(ref Guid pguidCmdGroup,
int cCmds,
[In(), Out()]
OLECMD[] prgCmds,
[In(), Out()]
OLECMDTEXT cmdText );
[PreserveSig()]
int Exec(ref Guid pguidCmdGroup, int nCmdId, int nCmdExecOpt, ref object[]
pvaIn, ref object[] pvaOut);
} Tag: DataGrid Scrollbar problem Tag: 60681
creating a singleton application
Hello,
How do I prevent my win form application being launched twice in the same
box? if one already exist I want to focus to that one instead of launching
another one.
thanks,
/m Tag: DataGrid Scrollbar problem Tag: 60678
CodeDom Serialization Problem
I have a problem with serializing user controls to
persistant collections with the Code Dom. I have followed
many of the examples I have found, and the serialization
works except for one problem.
I am using the attribute -
DesignerSerialization.Visibility.Content...
Somehow I am losing the "association" between the
instance of the collection I am serializing, and when the
control is reloaded (or when you run the application).
While you remain in normal design-time mode, everything
is serialized properly straight to the code-behind.
Everything is also removed properly straight from the
code-behind (when removing an object)... I have
implemented TypeDescriptors / Convertors / Designers /
etc...
But I still have this problem.
After I reload or run the app. - then what happens is it
becomes disconnected with the serialized collection. It
doesn't know that there was a previous instance of it
that needs to be de-serialized, instead the collection
acts like a new "blank" collection on each reload.
For instance...
Let's say you have a Parent/Container Control that holds
all your child controls inside it. Now you have a
custom-collection (inherits from collectionBase) that
holds the references of the child controls. The custom
collection is of course exposed as a property of the
parent control, standard OO design...
You drop the Parent/Container control on a form. Now you
add child controls to the Form. Well so far - so good.
The code is generated properly in the code-behind as such:
ParentControl.ChildControlCollection.Add(SomeChild)...
etc...
However, you reload the project or run the application.
The CODE is still in the code-behind, but the objects are
no longer physically appearing in the control, even
though the objects are still in the code behind.
Also, when you try to remove an object from the
collection, the object does not exist inside the
collection anymore, instead it only exists in the CODE
editor.
Somehow the collection is being re-instanced or
disassociated with the collection that has been
serialized.
Does anyone have any specifics or information about
where, when, and how the De-Serialization is taking place
during the automated
DesignerSerialization.Visibility.Content process?
I have gone over my code so many times looking for some
place I might have "over-wrote" the instance of the
collection. But it just isn't there, I just don't see why
the instance of my collection would be disassociated when
I run the program or re-load VS.NET...
Thanks for any info, (Really stuck here)
CoderGuy Tag: DataGrid Scrollbar problem Tag: 60675
BUG: Printing
Hi,
I am working on the PrintDocument, PrintDialog, PageSetupDialog and
PrintPreviewControl components of Visual Studio .NET 2003. My developement
machine is running Windows XP.
There are some problems I encountered while using them. Please note that,
the Regional and Language setting on my machine is using "Metric"
measurement system (where the default is "US"). In this case, the
measurement unit is "milimeters" and not "inches".
PROBLEM #1
``````````````
The first problem is with PageSetupDialog. The following code,
Dim pagesettings As System.Drawing.Printing.PageSettings
Dim pagesetupdialog As System.Windows.Forms.PageSetupDialog
pagesettings = New System.Drawing.Printing.PageSettings
With pagesettings.Margins
.Left = 100
.Right = 100
.Top = 100
.Bottom = 100
End With
pagesetupdialog = New System.Windows.Forms.PageSetupDialog
With pagesetupdialog
.PageSettings = pagesettings
.ShowDialog()
End With
' Values printed out are not the same as entered
With pagesettings.Margins
Console.WriteLine(.Left)
Console.WriteLine(.Right)
Console.WriteLine(.Top)
Console.WriteLine(.Bottom)
End With
will reproduce the problem I'm facing.
Before calling the ShowDialog() method of the PageSetupDialog component, I
have already set the Margins to 100. Although my OS's measurement system is
set to "Metric", Visual Studio .NET still uses inches (0.01 in) for it's
measurement unit. In my case, the Margins are set to 1 inch.
On calling the ShowDialog() method, what you see is the margins are all set
to 10 (and the unit is milimeters). On clicking the OK button, the
PageSetupDialog component will convert the value entered in it's dialog to
inches (0.01 in). As the result, the margins after the ShowDialog() is
called are changed to 39 (100/2.54=39.xxxxxx).
This surely is a BUG (or am I missing something here).
I have a solution for this problem and the code is as below.
Dim pagesettings As System.Drawing.Printing.PageSettings
Dim pagesetupdialog As System.Windows.Forms.PageSetupDialog
pagesettings = New System.Drawing.Printing.PageSettings
With pagesettings.Margins
.Left = 100
.Right = 100
.Top = 100
.Bottom = 100
End With
pagesetupdialog = New System.Windows.Forms.PageSetupDialog
With pagesetupdialog
.PageSettings = pagesettings
' Keep the original setting
Dim marginSaved As System.Drawing.Printing.Margins
marginSaved = pagesettings.Margins
' Convert to milimeters
pagesettings.Margins =
System.Drawing.Printing.PrinterUnitConvert.Convert(pagesettings.Margins,
System.Drawing.Printing.PrinterUnit.Display,
System.Drawing.Printing.PrinterUnit.TenthsOfAMillimeter)
' Show the page setup dialog
If .ShowDialog() = DialogResult.Cancel Then
' If user clicked Cancel, restore the saved margin
pagesettings.Margins = marginSaved
End If
End With
With pagesettings.Margins
Console.WriteLine(.Left)
Console.WriteLine(.Right)
Console.WriteLine(.Top)
Console.WriteLine(.Bottom)
End With
But there is a problem with it. The conversion between milimeters and inches
causes the measurement to be inaccurate.
PROBLEM #2
``````````
The OriginAtMargins property of the PrintDocument component does not work
properly when the PrintDocument is added into the PrintPreviewControl.
Setting the value to True does not effect the preview shown by
PrintPreviewControl but the printed result is correct.
PROBLEM #3
``````````
When handling the PrintPage event of the PrintDocument, if the
OriginAtMargins of the PrintDocument is set to True and I set,
e.Graphics.PageUnit = GraphicsUnit.Millimeter
then the top margin is measured as milimeters while the left margin is
measured as inches.
The problem discuss above might not be bugs but I have checked the MSDN
library but it does not seem to help much. Any help is really appreciated.
Thanks in advance. Tag: DataGrid Scrollbar problem Tag: 60674
Smart client using IE web control doesnt work.
It shows an error in ieexec relating to threading. Has anyone used the ie
control in a smart client. If so please help.
Rajesh Tag: DataGrid Scrollbar problem Tag: 60672
Option Strict and Late Binding
Hello,
I have the following code.
Private Sub ABC_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnA.Click, btnB.Click,
btnC.Click
if sender.name = "btnA" then
Do something etc, etc
else
Do something else etc, etc
end if
End Sub
This code works fine until I turn Option Strict On. Then
I get a blue line under the words "sender.name" with the
following message "Option Strict On disallows late
binding". I am unsure how to get access to the properties
of the button clicked in this situation using "sender".
Can anyone point me in the write direction?
Thanks
Felicity Tag: DataGrid Scrollbar problem Tag: 60671
Scaled Pen DashStyle
It appears that the DashStyle of a Pen object is not
effected by the scale transform like the pen's width is.
Is this true and if so is this an oversight? How do I
scale the existing DashStyles?
Thanks!
Bob
Pen pen = new Pen(Color.Red, 1.0f);
pen.DashStyle = DashStyle.Dash;
pen.ScaleTransform(0.1f, 0.1f); Tag: DataGrid Scrollbar problem Tag: 60663
Adding Row To Displayed Child Table Fails
Using vs 2003, vb.net, sql msde
I have a Parent/Child related datagrid and datatables. When only the parent
is displayed, I can add 200 rows in a loop to the child table with out a
problem and then display these new child table rows. If I display the Child
table first, and then try to add 200 rows, it fails on the first row adding
attempt with the following error. I am only adding rows to the DataSet
Child Table, not updating any datasource.
"A first change exception of type 'System.IndexOutOf RangeExcetpion'
occurred in system.windows.forms.dll
Additional information: Index was outside the bounds of the array."
What is going on?
Bob Day Tag: DataGrid Scrollbar problem Tag: 60662
.Net Application Updater
Hi
I am using .Net updater to distribute updated versions of the
application to clients through internet. Could somebody tell me how to
exactly create a public and private key pairs, signing the assembly
and deploy them. I read the document with App.Updater but could not
successfully proceed with that. If somebody could tell me step by step
of doing this, would be great.
thanks Tag: DataGrid Scrollbar problem Tag: 60661
Resource problems
Hi all,
I am writing a winforms application, and whenever I set the icon for the
main form, I get the following exception message (A
MissingManifestResourceException) on running it:
Could not find any resources appropriate for the specified culture (or the
neutral culture) in the given assembly. Make sure "ScoreSheet.resources"
was correctly embedded or linked into assembly "PMDLScorereTest".
baseName: ScoreSheet locationInfo: PMDLScorereTest.ScoreSheet resource
file name: ScoreSheet.resources assembly: PMDLScorereTest,
Version=1.0.1405.29676, Culture=neutral, PublicKeyToken=null
I don't understand what is going on here. The .resx file has a base64
encoding for this.icon. As far as I can remember, i havn't changed any
culture settings. Does anyone know what the problem is here?
As a note, this is the app.ico file that VStudio generates in a new project.
Thanks for the help
Adam Tag: DataGrid Scrollbar problem Tag: 60658
DataGridCell.GetHashCode() is a very bad hash function
This is the hash function used by DataGridCell:
public override int GetHashCode()
{
return (((~this.rowNumber * (this.columnNumber + 1)) & 0xffffff00)
>> 8);
}
I tested this hash function over 1000x1000 cells, and found only 4000
distinct hash values were generated. A good hash function should have
generated just under 1e6 distinct hash values.
Also, for small values of rowNumber and columnNumber (roughly, where
rowNumber*columnNumber < 256), GetHashCode() always returns the same
value, 65535.
I think the intention is for this hash function to operate akin to the
mid-square hash function of Knuth, but in practice, the result is
pretty bad.
All in all, this is a terrible hash function.
In fact, the treatment of hash functions throughout the MS libraries
is generally pretty bad.
Object.GetHashCode() returns object identity, a number that increments
by one for each object allocated. If you allocate a series of objects,
the difference between two successive hashcodes will be 1.
Throughout the examples in the MSDN docs, combining hashcodes is
inevitably shown as a.GetHashCode() ^ b.GetHashCode(). Given that
objects allocated close together in time will have hashcodes close
together, this is a very bad way of combining hash codes.
If youre going to use an object or struct as a key, except for
strings, you should always define your own GetHashCode().
A quick and dirty way to define your own GetHashCode() is to multiply
the system GetHashCode() by a large, odd, and preferably prime,
number.
class HashRand
{
private static readonly Random _rand = new Random();
public static int Next()
{
return HashRand._rand.Next() | 0x00010001;
}
}
class Key
{
private static readonly int _hashmul = HashRand.Next();
public override GetHashCode()
{
return base.GetHashCode() * Key._hashmul;
}
}
struct Key2
{
private static readonly int _hashmul1 = HashRand.Next();
private static readonly int _hashmul2 = HashRand.Next();
int x, y;
public override GetHashCode()
{
return x * Key2._hashmul1 + y * Key2._hashmul2;
}
} Tag: DataGrid Scrollbar problem Tag: 60657
A very good DYNAMIC sizing routine for DataGrids if you want it
It literally requires only one line of code to attach it to any
existing Winform DataGrid, you can give it percentages like the
ASP.NET data grid and minimum column widths, the default of course is
to size all columns equally, it's very cool and the columns always
take up the full client rect of your grid making it look very
professional. I can't believe I had to write this.
Email me at dearpolycarp @ hotmail.com ... Put DATAGRID in the
subject.
I'll send you a tiny little sample with the source code, use it at
will. Tag: DataGrid Scrollbar problem Tag: 60656
Datagrid and scrolling
My question concerns navigation with the DataGrid on my
Windows Form.
Private Sub btnNext_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnNext.Click
' Move to the next record
NextRecord()
' Highlight the entire row for user feedback.
grdXNew.Select(grdXNew.CurrentCell.RowNumber)
End Sub
' Move the BindingContext Position to the next record.
Public Sub NextRecord()
' The position of the binding context controls
the "current record"
Me.BindingContext(dtXNew).Position += 1
End Sub
The code seems to work fine, except that after
GrdXNew.Select is fired, the Datagrid scrolls back to the
first record. The row that was navigated to is selected,
but if it is not within the bounds of the grid, the row is
not viewable. The user would then have to scroll the
Datagrid to see what row is highlighted. It appears the
behavior is that the grid always scrolls to the top after
a selection is made programmatically.
My question is: Is there a way to maintain the highlighted
row in the viewable area of the grid?
Thank you in advance. Tag: DataGrid Scrollbar problem Tag: 60644
Simulating Longhorn Sidebar
Hi,
Is there a component available to simulate Longhorn style Sidebar on
Windows XP ? Or is there a sample application somewhere to show how to do
that ?
Thanks in advance and regards
Navin Tag: DataGrid Scrollbar problem Tag: 60642
Problem when changing button font at runtime
I create a simple Windows Forms application and drop a simple button
on the form with the designer. I define the Text of the button (i.e.
"Button test") and I set the button width so I have plenty of space to
display the text (i.e. 120). Then I add the following code in the
button's click handler.
private void button1_Click(object sender, System.EventArgs e)
{
button1.Font = new Font(FontFamily.GenericSansSerif, 10,
FontStyle.Bold);
}
When I click the button, the button's text is displayed with the new
Font but the last letter (t) is truncated and not displayed properly.
I can't isolate exactly the conditions in which this behavior is
produced but the above conditions produce the bug. The complete code
is below.
Any ideas on this? A bug in the button code? Any way to avoid this?
Olivier
---
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(120, 24);
this.button1.TabIndex = 7;
this.button1.Text = "Button test";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(216, 110);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
button1.Font = new Font(FontFamily.GenericSansSerif, 10,
FontStyle.Bold);
}
}
} Tag: DataGrid Scrollbar problem Tag: 60639
I need Microsoft.Web.Services Dll (Hell)
Hello All,
I am wanting to get a dll called Microsoft.Web.Services.
Can someone email me the dll? or send me the url to get to
it?
I down loaded WSE10SP1.exe, but I still don't have the dll.
Any help would be appreciated!
Ken Tag: DataGrid Scrollbar problem Tag: 60638