Question on Control.InvokeRequired and Cross UI Thread call?
Hi,
From MSDN documentation, it implies that any cross ui thread calls will
result in InvalidOperationException when one tries to access a UI object from
a non-creation thread.
I have a situation where someone is executing some code in a thread pool
(Threading.IsThreadPoolThread is true and so if Form.InvokeRequired is true)
and yet when it calls
// this.mainTabControl.InvokeRequired is true
TabControl tc = this.mainTabControl.TabPages[i];
it does not throw the InvalidOperationException, why? Is this because it is
not actually accessing the UI part of the control? If is like going through
its internal list?
Thanks.
Leon Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 106009
Datagrid problems
Hi
I have 2 problems with a datagrid
problem 1
I use a datatable as datasource and I don't want the last row to be
visible (the one where you can add new rows) how can I do this?
problem 2
I use the folowing code to hide some columns to the user
dataGrid_practicegrid.TableStyles[0].GridColumnStyles[3].Width =
0;
dataGrid_practicegrid.TableStyles[0].GridColumnStyles[4].Width =
0;
and it works the first time the code is executed, but when I repress
the button that executes this code the columns becomes visible again..
I find this very strange. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 106007
Accessing an Exchange/Outlook e-mail from our application ...
We have a WinForms v2 application whereby users need to take incoming
customer e-mails and place them into the customer's record in SQL Server 05
using drag and drop. We've finally managed to get most of the DnD issues
resolved. Now, we need to figure out how to best get a handle to the e-mail
messages.
The way we see this working is the user will have their Outlook client
running on their desktop, along with the WinForms application (it's a
customer service app). The user will open and read the e-mail - to see who
it's from, subject, where it should be stored, etc., etc. - then "drag and
drop" the message on to the Customer's record in our application.
We have never programatically worked with Exchange, or Outlook, before and
are curious where best to start? I'd say we need to get to fields like
Sender, Subject, Date & Time, and the Body.
Does anyone know of a class that represents e-mail messages that we can use
in this way?
Appreciate any and all help - thanks.
--
Stay Mobile Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 106005
Installer Dialog problem
Iâ??m trying to create an installer for an application. The installer has a
custom dialog with two checkboxes determining if shortcuts should get created
on the desktop and in the Start menu. Regardless what I do, and what I check
the shortcuts always get created in both.
In the User interface Setup I have:
Checkboxes (A):
Checkbox1Label Desktop
Checkbox1Property CHECKBOXA1
Checkbox1Value Unchecked
Checkbox1Visible True
In the FileSystem/Userâ??s Desktop I have the shortcut defined and the
properties are:
AlwaysCreate False
Condition CHECKBOXA1=Checked
Transitive True
I have tried all permutations of the condition I can think of (Checked, 1,
0, nothing) even named the checkboxes differently. Nothing helps. Can
somebody help? Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 106004
Drag & Drop ... getting a handle to the file that was dropped.
We are attempting to allow our users to use Drag n Drop onto a control in a
WinForms v2 application.
Within the control_DragDrop() event handler we want to determine the name
and location for a file that was dropped onto this control. We are
moderately familiar with performing DnD from within our application - we do
this between various controls within the app itself - but, a lot to learn
when it comes to DnD and external files from outside our application.
We are successfully determining that the user is trying to drop a file onto
the control with the following code in the DragEnter() event handler:
if (e.Data.GetDataPresent( DataFormats.FileDrop ))
{
Console.WriteLine("A file was dropped .......");
}
What we're trying to do now, is create a File object (or something similar
that you might recommend) using the file the user has dropped so that we can
get to its contents, file name, date it was created, etc., etc. Just not
sure how to get the handle to the file??
Thanks
--
Stay Mobile Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 106001
Cursors.Rotate
Is there a System.Windows.Forms.Cursors.Cursor object that indicates
'Rotation'? Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105996
Word Wrapping ListView ToolTips
Mostly I'm happy with the default behavior of the ListView ToolTips in
the app I'm working on. In detail view, they display the subitem text
if it's too wide for its column.
What's silly, however, is that the ListView's ToolTips won't word wrap
if the text is very long... they'll happily exceed the screen width, in
fact.
Using some interop with SendMessage, I can send LVM_GETTOOLTIPS to the
ListView's Handle, then send TTM_SETMAXTIPWIDTH to the returned ToolTip
handle. I can even verify that the width I'm setting is being set is
being stored: on a second SendMessage to the ToolTip of
TTM_SETMAXTIPWIDTH, the value I set is being returned. So everything
looks good.
Except... it doesn't actually work. The ToolTip still won't wrap the
text, which does contain plenty of spaces.
That's a little puzzling, so I thought I'd pose some questions here.
First, would there be more than a single ToolTip control associated
with a ListView, so that LVM_GETTOOLTIPS is perhaps returning something
other than the control shown when hovering over subitems? And if that's
the case, how do I get the correct handle?
Second, if I am indeed sending TTM_SETMAXTIPWIDTH to the correct
control, why wouldn't the setting be respected? I'm testing on XP SP2,
using the .NET 2.0 framework, so things should be pretty current.
Thanks in advance for any suggestions!
Dave Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105993
Datagridview databinding/refresh
I have two questions.
1. Is there a way to keep the datagridview datasource constantly bound to a
sql db? So that as soon as a change takes place in the db by any user, it is
updated on all screens. If so, how is that done? If not, what is the best
practice to perform this type of function?
2. In refrence to above, I have a timer that refreshes the data every 3
minutes. One problem here is the screen flickers when it refreshes. How
would i resolve this? And, if a user is scrolled to the bottom of the
datagridview, when the data refreshes in the grid, the scrollbar
automatically goes back to the top. How would i prevent this from happening
so the user stays on the record they're viewing. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105992
Disabling rows in datagridview
Hi,
I am new to the forms world and have a silly doubt.
I have form with a DataGridview and an "Add" button. When the user
clicks on the add button, one row gets added to the datagrid.
Now I want that when the user hits the "Add" button, then new row
should be added and all the previous rows should be disabled for
selection/editing.
How can I disable previous rows for selection/editing?
Here is my sample code (just example..won't compile)
private void buttonAdd_Click(object sender, EventArgs e)
{
// Add new row
DataRow row;
row = diagnosticsTable.NewRow();
// Then add the new row to the collection.
row["DIAGNOSTIC_NAME"] = "AddDiagnosticsName";
row["DIAGNOSTIC_DESCRIPTION"] =
"AddDiagnosticsDescription";
row["SYSTEM_NAME"] = "Newsys";
diagnosticsTable.Rows.Add(row);
this.dataGridViewDiagnostic.CurrentCell =
this.dataGridViewDiagnostic[1, 0];
}
Thankyou... Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105991
databinding in form conctructor
Hello,
a strange, but probably simple, problem drives me nuts:
I have simple databinding of textbox to bindingsource(bound to
dataset), created in form constructor:
public Form3(string xyz)
{
InitializeComponent();
Program.bs.AddNew();
textBox1.DataBindings.Add("Text", Program.bs, "cmType");
textBox1.Text = xyz; // <-nothing happens
}
all I want is to add a new row to dataset, and set a value of column
"cmType" programatically in form constructor. Problem is that result of
program above is blank textBox1, and no data in "cmType".
If i fill textBox1 in onFormShow event, everything goes ok.
Anyone can help?
thx Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105990
C# ComboBox help plz.
Hi all,
How do I get C# to populate a ComboBox with files from a folder?
They'll then be displayed into a DataGridView, but I think I got that
under control.
Another Q... if I wanted to make the ComboBox display the files in sub
selections like this:
Arts.resx
Arts.01.resx
Arts.02.resx
Movies.resx
Movies.ab.resx
Movies.cd.resx
Not in alphabetical order but just match similar names? Any help
thanks.
Much appreciated :-) Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105987
on datagridview row selection...
Hi all,
I'm a bit stuck with a method I'm trying to implement...
I have a datagridview that displays XML data, I want to select the row
& display the "value" column field of that rows contents to a
TextBox... then edit it there, then click on insert button to add the
text to the selected row column "value" ?
Also ... I may be typing in Japanese or French in the TextBox, so is
TextBox ok to use or should I use RichTextBox & will datagridview be
capable of displaying these characters once I save them to XML?
Thanks In Advance. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105984
Alternative update location for click once application
Hi Everybody,
At the moment I have a project which is being updated from a http server.
What I want to do is to change the update location from client side. I am
deploying the updates manually meaning I am creating manifest files by hand.
Forexample think of 3 servers. Asia, europe and Us. The default is that Asia
updates from Asia, Europe from Europe an so on. But what I need is when Asia
is down then Asia clients can try Europe and US servers. Is there a way to do
this? I will really appreciate if anyone can help.
Thanks, Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105982
Repaint order of invalidated child controls
Hi,
I'm developing a hex editor control, and it displays the hex and raw
views into the document using a number of subcontrols. This is great,
but now I'm seeing a bug when I scroll my control very fast.
How it should look:
http://www.omega-prime.co.uk/files/invalidate-desired.png
How it does look:
http://www.omega-prime.co.uk/files/invalidate-bug.png
Since scrolling the control forces all the subcontrols to invalidate,
and they repaint separately, it can occur that they get out of sync on
screen (in this case, the selection is clearly different for each
control). This, however, would be OK if I could just get Windows to
redraw the least recently repainted control first (the flicker would
become unnoticable).
The problem is that this doesn't seem to be possible. The order in which
I issue Control.Invalidate calls is irrelevant! For example:
INVALIDATE TextAdapter
INVALIDATE SeparatorAdapter
INVALIDATE HexAdapter
INVALIDATE SeparatorAdapter
INVALIDATE AddressAdapter
PAINT AddressAdapter
PAINT SeparatorAdapter
PAINT HexAdapter
PAINT SeparatorAdapter
PAINT TextAdapter
This can lead to situations like this (when scrolling fast):
INVALIDATE AddressAdapter // Scrolled for the first time, invalidate
everything
INVALIDATE SeparatorAdapter
INVALIDATE HexAdapter
INVALIDATE SeparatorAdapter
INVALIDATE TextAdapter
PAINT AddressAdapter // Windows starts to paint...
INVALIDATE AddressAdapter // Scrolled again, only invalidate what needs
redrawing in a vain hope that repaints work as a queue
PAINT AddressAdapter // Windows starts to paint again, but not as a
queue, so e.g. AddressAdapter is always redrawn with top priority,
leading to the bug
PAINT SeparatorAdapter
PAINT HexAdapter
PAINT SeparatorAdapter
PAINT TextAdapter
So, is there a clean way to make invalidate events occur in order? Or is
there a better way to handle this graphical bug?
Thanks in advance!
Max Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105981
.net 3.0: transparent windows?
Hi,
For those who have the lucky opportunity to test vista rc2, the sidebar's
Add Gadget window has a nice transparency in aero. I was wondering if anyone
knew the code to reproduce a similar transparent window?
Thanks all,
Timothy. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105979
tooltip problem on framework 2.0
Hi all,
I am experiencing a strange problem for the call setToolTip while
running my application on frmaework 2.0. I have found 2 messages on
google discussing the same issue but there are
no replys
It dumps saying something like
System.InvalidOperationException: Adding the tip to the native ToolTip
control did not succeed.
at System.Windows.Forms.ToolTip.SetToolInfo(Control ctl, String
caption)
at System.Windows.Forms.ToolTip.CreateRegion(Control ctl)
at System.Windows.Forms.ToolTip.CreateAllRegions()
at System.Windows.Forms.ToolTip.get_TopLevelControl()
at System.Windows.Forms.ToolTip.CreateRegion(Control ctl)
at System.Windows.Forms.ToolTip.HandleCreated(Object sender,
EventArgs eventargs)
at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.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.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
The strange thing about this that it cannot be caught in the try catch
blocks.
Actually I have set the tooltip to most of the controls in my
application. It sets and displays it properly but somewhere in the
middle it dumps. The trace I am getting won't tell me exactly to which
tooltip it dumps so I am not able to figure out exactly.
Does anybody has found any solution for such problem
Thanks in advance Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105978
The cost of Invoke()... can it be done faster?
This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C6F459.ACA68A20
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi guys..
I've got a function that copies one file to another location. The file =
it copies is currently about 36mb. I've got an event being fired after =
after every 32k buffer read from FileStream.Read(), containing the bytes =
read thus far and the total bytes to read.
When I don't invoke to update the UI status, the copy currently =
completes in just under 3 seconds. With a UI status invoke, it takes 23 =
seconds.
Essentially this is my event handler:
if (this.InvokeRequired)
{
this.Invoke(new ProgressRaiseDelegate(progEvent), e);
}
And progEvent simply involves setting a progress bars value to the =
current value. Is there a way this can be significantly sped up? Cheers.
------=_NextPart_000_0008_01C6F459.ACA68A20
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.5700.6" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hi guys..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I've got a function that copies one =
file to another=20
location. The file it copies is currently about 36mb. I've got an event =
being=20
fired after after every 32k buffer read from FileStream.Read(), =
containing the=20
bytes read thus far and the total bytes to read.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>When I don't invoke to update the UI =
status, the=20
copy currently completes in just under 3 seconds. With a UI status =
invoke, it=20
takes 23 seconds.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Essentially this is my event =
handler:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT color=3D#0000ff size=3D2>
<P><FONT face=3D"Courier New">if</FONT></FONT><FONT face=3D"Courier =
New"><FONT=20
size=3D2> (</FONT><FONT color=3D#0000ff size=3D2>this</FONT></FONT><FONT =
size=3D2><FONT=20
face=3D"Courier New">.InvokeRequired)<BR></FONT><FONT=20
face=3D"Courier New">{<BR> </FONT></FONT><FONT=20
face=3D"Courier New"><FONT color=3D#0000ff size=3D2>this</FONT><FONT=20
size=3D2>.Invoke(</FONT><FONT color=3D#0000ff size=3D2>new</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#008080 =
size=3D2>ProgressRaiseDelegate</FONT></FONT><FONT=20
size=3D2><FONT face=3D"Courier New">(progEvent), e);<BR></FONT><FONT=20
face=3D"Courier New">}</FONT></FONT></P>
<P><FONT size=3D2><FONT face=3DArial>And progEvent simply involves =
setting a=20
progress bars value to the current value. Is there a way this can be=20
significantly sped up? Cheers.</FONT></P></FONT></DIV></BODY></HTML>
------=_NextPart_000_0008_01C6F459.ACA68A20-- Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105974
How to insert a row at the top of the datagrid?
This is a multi-part message in MIME format.
------=_NextPart_000_0006_01C6F42D.3D809360
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi:
I have a problem to insert a row at the top of the datagrid. In the data =
table (the datasource of the datagrid), no matter I insert the datarow =
at 0 or rows.count-1 position, the new row always appear at the bottom =
the datagrid, but I want it appear on the top. How can I do it?
Thanks,
Dennis Huang
------=_NextPart_000_0006_01C6F42D.3D809360
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2912" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I have a problem to <FONT size=3D1>insert a row at =
the top of=20
the datagrid. In the data table (the datasource of the datagrid), no =
matter I=20
insert the datarow at 0 or rows.count-1 position, the new =
row always=20
appear at the bottom the datagrid, but I want it appear on the top. How =
can I do=20
it?</FONT></FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>Thanks,</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>Dennis Huang</FONT></DIV></BODY></HTML>
------=_NextPart_000_0006_01C6F42D.3D809360-- Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105973
Access form from component
Hello.
I have created a custom component. At run-time I need to access the Form
that is hosting my component from inside my component. Is this possible?
Thanks in advance. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105972
DataGridView / EndEdit and CellValidating event
Hello
I have a DatagridView with a checkBoxColumn.
When I Check with mouse a row (and so toggle the checkBox) I want launch a
EndEdit() method on my DataGridView
I can do this with an tips : I create a class inherits from
DataGridViewCheckBoxCell and plug an instance on my column by CellTemplate
property, this class override OnMouseDown method ...
BUT I want launch something like CellValidating event on my datagrid (or
somewhere) to intercept the check and perhaps cancel the user's change
(becaule a rule will not be respected)
this event is not launched !! :-( It is just launched When I change the
current cell !!
How can I do this ?
It seem very basic functionnality, It is certainely possible to do this, but
How ????
thanks for your help ! Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105971
Question regarding MDI
Hello,
I am VERY new to WindowsForms but VERY eager to learn.
I am in the process of creating an MDI application to manage High Sensitivity Customers within our organization. I am working on the first form which will host the login controls to the application.
I noticed that when I change the type of the form to an isMDIcontainer to TRUE the background color of the application changes to dark grey. No matter what I do I cannot change the background color.
This is really ugly. I even tried a background color however, when I change the controls background to transparent, they are wrapped with that dark grey color instead.
Does anyone have any ideas or resources I can view to rectify my issue?
Thank you very much.
Tim
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105962
ListView ownerdraw column headers
I have a question for anyone who might be able to help... I am in the
process of building a custom listview, and am dealing with sorting, and
wanting to use the asc/desc sort indicators in the column header... i
have tried setting the parent's SmallImageList property and using those
images as sort order indicators, but the ListView items also try to use
those images, which screw up the way the ListView renders in some
situations.
Drawing the column header is an easy enough way around this, but I am
running into trouble with dealing with the mouse over behaviour. I
attempt to access the MousePosition, and then test if the bounds of the
columnheader contain that point. This works just fine - however...
When you are moving from one column to another, from right to left
(this is the important part), the rightmost column (the one you just
came from) still evaluates the
e.Bounds.Contains(this.PoiintToClient(Control.MousePosition))
expression to 'True'...
Additionally, in the same Right to left motion, the columns' "hover"
seems to be off by one (delayed) as you mouse over...
So, if we have 4 columns {0,1,2,3} and we are moving Right to Left,
without leaving the vertical bounds of the ListView's column header...
If the mouse cursor is over column...
[3] --> [3] is "highlighted"
[2] --> [3] is "highlighted"
[1] --> [3] and [2] are "highlighted"
[0] --> [3] [2] [1] are all highlighted.
I don't understand entirely why this might be. Since it doesn't
exhibit any of this behaviour at all when you move over the columns
from Left to Right, I am guessing that the column header might
"virtually" extend all the way to the left, or something like that...
Is there a better way to determine whether or not the mouse is hovering
over the specific bounds of the column header?
Find the ColumnHeader OwnerDraw code below...
Thanks for any help you might be able to provide...
protected override void
OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) {
e.DrawDefault = false;
Color normal = SystemColors.Control;
Color hover = SystemColors.ButtonHighlight;
Color hoverPress = Color.LightGreen;
Color normalBorder = SystemColors.InactiveBorder;
Color hoverBorder = Color.FromArgb(227,145,79);
Color verticalDiv = SystemColors.Highlight;
RectangleF txtRect = RectangleF.Empty;
Point mPoint = this.PointToClient(Control.MousePosition);
bool MouseHover = e.Bounds.Contains(mPoint);
Brush bgBrush;
if (MouseHover)
bgBrush = new SolidBrush(hover);
else
bgBrush = new SolidBrush(normal);
e.Graphics.FillRectangle(bgBrush, e.Bounds);
SizeF txtSize = e.Graphics.MeasureString(e.Header.Text, this.Font);
switch (e.Header.TextAlign) {
case HorizontalAlignment.Left:
txtRect = new RectangleF(
4 + e.Bounds.Left,
(e.Bounds.Height - txtSize.Height) / 2,
txtSize.Width,
txtSize.Height
);
break;
case HorizontalAlignment.Center:
txtRect = new RectangleF(
(e.Bounds.Width - txtSize.Width) / 2 + e.Bounds.Left,
(e.Bounds.Height - txtSize.Height) / 2,
txtSize.Width,
txtSize.Height
);
break;
case HorizontalAlignment.Right:
txtRect = new RectangleF(
(e.Bounds.Width - (e.Bounds.Width - txtSize.Width)) +
e.Bounds.Left,
(e.Bounds.Height - txtSize.Height) / 2,
txtSize.Width,
txtSize.Height
);
break;
}
e.Graphics.DrawString(e.Header.Text, this.Font, Brushes.Black,
txtRect);
Brush divBrush = new SolidBrush(SystemColors.Highlight);
Brush borderBrush = new SolidBrush(normalBorder);
//Draw the vertical divider if we aren't hovering
if (MouseHover)
borderBrush = new SolidBrush(hoverBorder);
if (!MouseHover)
e.Graphics.DrawLine(new Pen(divBrush, 1.25F), e.Bounds.Right - 2,
e.Bounds.Top + (0.20F * e.Bounds.Height), e.Bounds.Right - 2,
e.Bounds.Bottom - e.Bounds.Height / 3);
// draw bottom border
e.Graphics.DrawLine(new Pen(borderBrush, 2.0F), e.Bounds.Left,
e.Bounds.Bottom - 1, e.Bounds.Right, e.Bounds.Bottom - 1);
base.OnDrawColumnHeader(e);
} Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105955
Show ToolTip on every Control continuously
Hi,
Using VB.NET 2.0, Windows Forms.
I want the ToolTip to be shown on every TextBox, ComboBox and DataGridView
continuously, and show the contence of these controls. Is there a way to add
the ToolTip automaticly for all these controls, without having to link it
the whole time to them for every new Control I put on my Forms?
And regarding the DataGridView: The ToolTip doesn't show the whole value of
every Cell, but cuts it off when it's too long. how to get around this?
Thansk a lot in advance,
Pieter Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105954
MenuStrip
I want to close MenuStrip. How to do that?
I send ALT with SendKeys.Send("%") and MenuStrip is closed. It's OK but
sendkeys isn't ok for me in all cases.
What another way to close MenuStrip?
Which method invokes SendKeys.Send("%") in MenuStrip class?
Whitch method is executed before MenuStrip.Deactivate event?
charlie Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105953
TypeConverter derivations failing to convert to InstanceDescriptor
Setup:
I have a C# 2.0 Conrol Library project and a Windows Form project in a
solution. I am developing winform controls in teh library and the winform
project has just a single form for testing these controls. The library
project is referenced by the winform proect using a project reference rather
than a static dll.
Some of my controls require custom TypeConverters, basically so I can sort
the properties and handle string to control conversions, etc... I actually
derive from ExpandableObjectConverter to take advantage of some of the extra
features of that type,specifically relating to PropertyGrid usage.
Problem:
If I drop one of my controls on the test form, everything works just fine.
However, if I make any changes whatsoever to the control, even if it is to
add a comment, and recompile, the control is no longer able to serialize
properties of the type that is using my custom converter. I get errors such
as the following:
"Code generation for property 'TabStyle' failed. Error
was:''SuperTabStyleConverter' is unable to convert
'INTZControls.SuperTabStyle' to
'System.ComponentModel.Design.Serialization.InstanceDescriptor'.'"
I also occasionally get the following error:
"Unable to cast object of type 'INTZControls.Tabstrip3D' to type
'INTZControls.TabStrip3D'."
I assume the second one is due to the fact that the controls are no longer
binary compatible, but this is just a guess. The first one just blows my
mind. If I do a full recompile, shut and restart VS2005, everything works
again. The other concern I have is that this code runs without any problems
within VS2003, even after making significant changes to the control source.
Here is an example of one of my type converters:
public class TextStyleConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext context, Type
destinationType)
{
if ((destinationType == typeof(InstanceDescriptor)) || (destinationType ==
typeof(string)))
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
ConstructorInfo ci = typeof(TextStyle).GetConstructor(new Type[] { });
if (ci != null)
{
return new InstanceDescriptor(ci, null, false);
}
}
else if (destinationType == typeof(string))
{
return value.ToString();
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type
sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
return TextStyle.Parse(value.ToString());
}
return base.ConvertFrom(context, culture, value);
}
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext
context)
{
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext
context)
{
return true;
}
}
Here is the definition of the class that uses this converter:
[TypeConverter(typeof(TextStyleConverter))]
public class TextStyle
{
///
}
Here is the property in the control that uses this class:
[Category("Appearance"), Browsable(true), Description("The text style used
to display the items in the control"),
DefaultValue(typeof(TextStyle), "Microsoft Sans Serif,
8.25pt;ControlText;MiddleCenter;Normal"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public TextStyle DefaultTextStyle
{
get
{
return m_DefaultTextStyle;
}
protected set
{
m_DefaultTextStyle = value;
this.Refresh();
}
}
Ideas? Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105949
Windows forms with html content
Hello,
Could somebody tell me how or where can I find information about how to
build windows applications but with html content, how to handle button
clicks etc...
Example apps are like Windows Vista Upgrade Advisor and Norton Antivirus
2006.
Thanks! Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105945
Controling form loads and redrawing
Couple of questions:
Is there a way to prevent events form frying until a form initializes
(during component initialization) loads?
Is there a way form keeping a form from redrawing its self until al the
updates and events are completed? It seams to me there was a way to do this
in VB6.
I am using VB.Net 2005
Thank you,
--
Mike Reed Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105941
Running a .NET 2.0 App from a network location
We have an application that we need to run from the network, however, it uses
many assemblies from the directory it is run from. I have already gone down
the road of creating a CodeGroup and PermissionSet from the .NET2.0
Configuration tool and the program continues to crash when executed.
Is there some way that we can run this app and allow access to all of the
assemblies in the remote directory? This will help us in setting up the
InstallScript as well for final deployment.
Thanks. -Devin Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105940
Dynamic MDI problems
Hi,
I'm creating a game dev kit where I need to switch between MDI and SDI mode.
MDI is used when displaying the IDE with editors etc, in SDI mode only the
"game" window is displayed, optionally with a few editors remaining open.
However, setting MdiParent once the child windows has been Shown() causes
strange refresh and focusing problems, e.g. a child window will not receive
focus when clicking on anything else than the title bar or resize borders.
It's very easy to recreate the problem; I can post the code if necessary.
I don't want to Close() the forms and re-open them, because there's a lot of
complex data in them that I don't want to have to serialize for loading at
re-load time.
Can I do anything about this? Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105938
How to change the size of the ErrorProvider hint
Hi.
Is it possible to change the size of the ErrorProvider tool tip?
Some of my text messages are to long.
thanks and best regards,
Jan Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105937
Visual Inheritance: Can I add custom properties to properties window?
Hi,
I created base UserControl for visual inheritance. The base control includes
the following property:
[Category("Appearance")]
[Description("The button text")]
[DefaultValue("Hi")]
public string ButtonText {
get {return this.button1.Text;}
set { this.button1.Text = value; }
}
But the property "ButtonText" does not appears in property window.
How can I add property window support to my Visual Inheritance procatice?
Thank you,
Max Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105934
Deployment/Debugging Question
Let me preface this by saying I've been primarily an ASP.Net developer
over the last few years and have just started working with Winforms.
My application will be a standalone program that will access FoxPro
database files. A typical installation would install my exe in
C:\Program Files\My Company\My Application. I want my database files to
go in C:\Program Files\My Company\My Application\Data. I've added the
Data folder to my project and selected the build action as content for
each Foxpro item inside it.
My question is with determining the path to the database files for my
connection string. I'll be able to determine the Data folder path using
Application.StartupPath. However, when debugging, the exe is compiled
and executed from the bin folder. Thus, the database path is incorrect
when using Application.StartupPath.
How can I simulate the install structure when developing and debugging? Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105933
Getting list of Website from IIS "Web Sites" Folder
hi guys,
few days back i've posted a question regarding how can i get the list
of the websites form the IIS, at this location:
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/97f4f07b8b46a397/41372cde30df29e7?lnk=st&q=how+to+get+list+of+websites+from+IIS+C%23&rnum=1&hl=en#41372cde30df29e7
and i got a nice replay. it worked.
now the problem is different when i tried the code on the different
webserver which has lots of websites but not under the "Default Web
Site" directory. most of the Websites are under the "Web Sites" folder.
and now i want to retrive all those websites list from the IIS. i tried
to get the type of the folder "Web Sites", but i didnt get anything out
of it.
can anyone tell me how can i get all of the websites from the folder
called "Web Sites".
Tools:
IIS 5.1 on Microsoft Windows Server 2003
C#.net 2005
thanks,
Lucky Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105924
replicating tooltip functionality
I wish to create a tooltip style control to show information about items
being dragged in a tree view.
My problem is that I cannot capture the mouse in the treeview ( and hence
have the tooltip follow the mouse when it moves outside the treeview control
), presumably because once the tooltip is shown it becomes the foreground
window.
Any possible solutions would be welcome ( I have thought about wrapping the
Win32 tracking tooltip, but I require more sophisticated tooltip content than
just text ).
Thanks,
Andrew. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105923
Create a base maintenance form: design and implementation recomendations
Hi all,
I'm doing a WinForm Project for .NET 2.0 platform and have some design and
implementation questions for my UI interface.
I have recently discovered that some complex controls (like DataGridView)
doesn't works well with visual inheritance (it can't be modified directly in
the inherited form although visibility of the control is public or
protected).
Now I have to do some simple maintenance forms to update/insert/delete
users, companies .
All are very similar: a DataGridView with some columns, a "Cancel" button
and an "Update" button.
The DataGridView would be linked to a BindingSource Control and this to a
Typed Dataset.
What is the best approach to have a base maintenance form to avoid coding in
the descendant forms?
I want to edit the columns from the DataGridView for every maintenance form
to adjust titles, size .
Thanks,
Alex B. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105922
discarding user actions on a form while in busy state
Hi,
I can't seem to figure out a decent way to do this. I have a small
window, and I need to discard user input while performing some lenghty
task. For example, if the user wants to sync the app with a server, and
this takes time. The proper behavior would be to change the cursor to a
busy cursor, and prevent the user from touching any control on the
form. Of course, painting should still be done, and the form should be
able to move and resize (user actions like move, resize, maximize,
minimize). When the job is done, the cursor changes back to the default
one, and the user is able to interact with the received data.
I've seen various sugestions:
- disable the controls (or the whole form): not good, as the appearance
of the controls changes dramatically; also, there seems to be problems
with the cursor, it won't show properly on a disabled control (it
displays the default cursor, not the one I set);
- put a transparent form on top of the current form: I'm interested in
this, if anyone can provide bits of code, I would really appreciate it.
However, I don't know if this is supported on all systems (I'm
interested mainly in XP, Win2003, and maybe Win2000).
- catch all events in a WndProc: how do I do this? I've overriden the
WndProc of my form, yet not all messages pass through this. I am still
able to interact with the controls...
I really appreciate any help on this, guys (and girls). :)
Cheers,
Cosmin. Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105920
AnimateWindow and popup window
I'mwriting a popup system for my application.
I'm using the win32 call ShowWindow to show my window.
Now I just stumbled on an other win32 call: AnimateWindow
And while that seems very appropriate for the popups it has the very
infortunate effect of showing a blank window!
All the child control have disappeared!
Any idea what going on?
--
Regards,
Lloyd Dupont
NovaMind Software
Mind Mapping Software
<www.nova-mind.com> Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105917
instal basics
I can't install dot net charting ver4,
build solution without error but
in
public MainForm(){
InitializeComponent() <<<<< Error
......
}
Error= "Couldnot load file assembly 'dotnetCharting.winform", version
4.0.94892324, Culture=neutral, PublicKeyToken=c8374837849' or one of its
dependencies can not be found
Did i install incorrectly (if so please explain again for me) or my C#
express doesn't fit this dotnetcharting ver4 ?
Thanks Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105916
ListView, ColumnHeader.Width when using multiple Fonts
Here is an issue I've been struggling with for a day now, I wanted to share
what happened with the group and find out if I have experienced (and worked
around) a bug, or if there is something that I missed. I am using Visual
Studio .NET 2003 with C#.
The goal: I need to make sure that in a ListView control, the columns are
drawn wide enough to display the text of the ListViewItems. Here's the
catch: ListViewItem.Font may not be the same as the ListView.Font.
Problem #1: ColumnHeader.Width does not take Font into account.
Should be easy... just use (ColumnHeader.Width = -1), right? Sorry, no.
Using the Width = -1 shortcut does not appear to take into account the fact
that one of the ListViewSubItems in that column may be using a font that is
wider than the ListView.Font.
Workaround #1:
I used ListView.CreateGraphics to create a graphics object, and then used
Graphics.MeasureString() like so:
// Assume listView.Font is "Microsoft Sans Serif", 8.25
// Assume listViewItem.Font is "Lucida Console", 8.0
Graphics g = listView.CreateGraphics();
foreach (ColumnHeader ch in listView.Columns)
{
ListViewItem.ListViewSubItem listViewSubItem =
listViewItem.SubItems[columnHeader.Index];
int neededColumnWidth = g.MeasureString(listViewSubItem.Text,
listViewSubItem.Font).ToSize().Width;
if (ch.Width < neededColumnWidth)
{
// Make the column wider
ch.Width = neededColumnWidth;
}
}
Problem #2: In the above example, the listViewSubItem.Font returns the same
value as listView.Font! I would have expected that listViewSubItems would
inherit their font from the parent ListViewItem by default.
Workaround #2: It is fortunate that the Font is identical for each element
of ListViewItem.SubItems, so I just substituted "listViewItem.Font" for
"subListViewItem.Font".
// Assume listView.Font is "Microsoft Sans Serif", 8.25
// Assume listViewItem.Font is "Lucida Console", 8.0
Graphics g = listView.CreateGraphics();
foreach (ColumnHeader ch in listView.Columns)
{
ListViewItem.ListViewSubItem listViewSubItem =
listViewItem.SubItems[columnHeader.Index];
int neededColumnWidth = g.MeasureString(listViewSubItem.Text,
listViewItem.Font).ToSize().Width;
if (ch.Width < neededColumnWidth)
{
// Make the column wider
ch.Width = neededColumnWidth;
}
}
Problem #3:
With the above code, I can see that the columns are indeed resizing to
become wider---but not quite wide enough to display all the text.
Problem #4:
Even when all the ListViewItems are using the same font as the parent
ListView, using (Width = -1) appears to jam the text against the right side
of the column---there is no padding on the right side of the column like
there is on the left.
After doing some research, I believe that this is related to some hardcoded
padding versions of .NET, similar to this bug which says, "Internally, the
Width of a ColumnHeader is padded with some predetermined constant when it is
changed programmatically. This padding is not in effect if the Width of the
ColumnHeader is changed through the user interface."
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B179988
This article implies that the hardcoded padding values are 29 for get_Width
and 30 for set_Width.
Final Workaround:
Whenever adding or modifying a ListViewItem or one of its SubItems, I also
call the following method instead of simply using (columnHeader.Width = -1;),
which appears to do the trick
/// <summary>
/// Ensures that each column in the list-view is wide enough to the given
text written
/// in the given font. Normally you can use ColumnHeader.Width = -1 (or
-2), but in
/// this application there are several ListView controls that use a
different font for
/// its items and headers. ColumnHeader.Width autosizing appears to
calculate the width
/// for each ListViewSubItem using the ListView.Font instead of the font of
the widest ListView.Item.
/// This method is not thread-safe.
/// </summary>
/// <param name="ch">The column header to be widened. It must have a valid
parent ListView.</param>
/// <param name="subitem">The subitem whose width is to be measured.</param>
private void SetColumnHeaderWidth(ColumnHeader ch, string stringToDisplay,
Font fontOfString)
{
if (null == ch)
{
throw new ArgumentNullException("ch");
}
ListView lv = ch.ListView;
if (null == lv)
{
throw new ArgumentException("The ColumnHeader must have a parent
ListView.", "ch");
}
// This is used for measuring items for the arguments listview
// to make sure the columns are wide enough to see their data.
Graphics g = lv.CreateGraphics();
try
{
int subitemWidth = g.MeasureString(stringToDisplay,
fontOfString).ToSize().Width;
int defaultStringWidth = g.MeasureString(stringToDisplay,
lv.Font).ToSize().Width;
// HACK 10-17-06 SEC: When setting the column header width
programatically,
// it appears to set it just a hair too small for the text you specified.
// I believe that this is related to some hardcoded padding where in
older
// versions of .NET, for example with this bug:
// http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B179988
// "Internally, the Width of a ColumnHeader is padded with some
predetermined
// constant when it is changed programmatically. This padding is not in
effect
// if the Width of the ColumnHeader is changed through the user
interface."
// According to the aforementioned article, these hardcoded values are
// 29 for get and 30 for set.
if (ch.Width < subitemWidth + 29)
{
ch.Width = subitemWidth + 30;
}
}
finally
{
// We *must* manually dispose of the graphics now that we are done with
it,
// per MSDN documentation for Control.CreateGraphics method:
// "The returned Graphics object must be disposed through a call to
// its Dispose method when it is no longer needed."
if (null != g)
{
g.Dispose();
}
}
}
Since I did say that this post is a question, my questions are:
1. Has anyone else encountered these issues and did you find a better way to
resolve them?
2. Are any of these problems known bugs? If so, have they been resolved in
more modern releases of Visual Studio .NET/Visual C# ?
--
Sarah Cartwright Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105907
Dataview.Rowfilter help
hey guys
I am tring to implement a filter in a datagrid. I am using a datatable
which is the datasource for the grid.
I need to filter set of rows. i.e. from row 1 to row count. i need to
keep my row 0 intact, which is an option to add a new person.
textbox key up code looks like this:
string strRowFilter = String.Concat("Name LIKE '%", txtName.Text,
"%'");
dv.RowFilter = strRowFilter;
grdNames.DataSource = dv;
plz help
sunny Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105905
CheckListBox row color ...
Hi
I have a CheckedListBox and I like to set the color of each row depending on
a value of the specific item in that row. I can't find a DrawItem event like
in the ListBox to hook on to ... Is there a way to achive this? I can get a
rectangle for each specific item (and row). Is there a way to use this?
Cheers.
Richard Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105901
custom listview - checkbox problem
seeking a little input on a problem I am seeing -
Background...
I have developed a custom listview object in .NET fx 2.0 - it supports
drag/drop operation, images in subitems, and sorting via specific
datatypes -
to provide the custom sorting functionality, I had to implement custom
column headers and a column collection object for use in the listview
for visual designer support. to support the image in subitems, i
implemented a custom SubItem class..
the listview itself is OwnerDraw, but unless there is a specific need
for owner draw (i.e., the SubItem is an image), I just set
e.DrawDefault = true and let the base class take care of the drawing..
##
the problem I am seeing is when CheckBoxes=true on the ListView... The
checkboxes are rendered, but it appears as though the vertical offset
is not calculated properly (?)... All of the subitems (text) are
rendered in the appropriate position, but the Checkbox is about "1/2 a
row" too high within the ListView, which leads to the BackGround
painting of the next Item to overlap the Checkbox.
I have done a screen dump and checked the spacing, and the vertical
spacing is correct, it's just higher than the rest of the listview
item.
I've tried to reproduce this behaviour using a simple OwnerDraw
listview "test" object, but have yet been unable to emulate the
problem... does anyone have any good ideas of where to start looking
for the problem? I would suspect the column header to be the cause of
the problem, but everything else renders with the proper vertical
positioning.
thanks - Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105896
Strange error when app starts
I have a strange (to me) problem with a c# forms application that I am
developing. The application is installed on approxmatly 30 Windows XP
machines and until recently they all worked perfectly. However since I have
updated the application to a new version one of the machines fails with an
unhandled exception when the application starts. The code in program.cs
works fine and anything before the InitializeComponent(); method in the main
form. As soon as the aplication enters the InitializeComponent method it
crashes with mention of a filenotfound exception.
I have copied the application folder from the failing PC to a good PC and it
works fine which leads me to believe that it must be a system file that is
missing. Likewise if I copy the program folder from a good PC to the failing
one it again fails.
I have reinstalled the app and the .Net 2 framework but to no avail.
Having only done "basic debugging" I'm now a bit stuck.
Any help would be appreciated Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105895
Single instance help!
Apologies for what must seem a newbie question (but I'm a newbie!)
I'm building an MDI app, and have declared new instances of several child
forms in a module. Then, in the parent form (where the IsMdiContainer
property is set to True) I simply Import the module, and then behind some
button click events I call the child forms with something like;
FrmChild.Show()
I'm doing it this way because I don't want users to create multiple
instances of the same child form.
However, I don't know how to set the mdiparent property of these child forms
when I'm declaring them in a module.
If I declare them in the code of parent form I'd use something like;
Dim MyChild As New Form
MyChild.MdiParent = Me
MyChild.Show()
But this doesn't work when declaring the child forms in a module.
I know there's probably a very simple explanation. Please help! Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105894
How to use standard expand/collaps buttons of TreeView
Hi,
I'm building my own tree-like control and would like to use the
standard expand (plus-sign) and collapse (minus-sign) buttons used by
the Windows TreeView control.
How can I do that? Are the standard buttons icons that I can load from
a Windows dll or can I paint similar icons myself, e.g. using the
ButtonRenderer class?
I'm using C# and .NET 2.0.
Thanks in advance
Ulrik Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105892
DataGridViewComboBoxColumn
Does anyone know how to set the selecteditem on a
DataGridViewComboBoxColumn?
I am bringing back a result set in the datagridview and need to pick a
specific item from the DataGridViewComboBoxColumn of each row.
Thanks Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105886
Creating abirtray forms on UI thread
Hi,
I have a Logging class.
Part of the job of the logging is to create a "tracewindowform", if
required.
It doesnt make sense to pass a reference to the UI thread, since the logging
request might be from a non UI thread.
Is there any way that an arbitrary thread can find a reference to its UI
thread, or parent form, and then ask it to create a tracewindowform on its
behalf?
Shak Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105884
How to set a C # form never be focused?
Hello all,
Here comes a C# Form focus controlling question.
I write a C# program that only contains a form and will attach to a
general process when I execute it, (e.g.: Notepad.exe) Now, the C# form
can display successfully without stealing the focus from the Notepad
process, i.e. show-no-activate, by using [DllImport( "user32.dll" ) ]
and call the SetWindowPos as follows:
{{{
SetWindowPos( handle, (IntPtr) HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW );
form.Visible = true;
}}}
My planned next step is to prevent the C# form from getting the focus
when I click on it. That is, it is hoped that the focus should be
always on the attached application such as Notepad. Does anyone know
how to do that?
James S. Jan
shihyi@iis.sinica.edu.tw Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105877
Writing Data In Tabular format in Text File.
Hi guys,
i want to write some data in tabular format in text file. i've data in
strings and i want to write like this in file
col1 col2 col3
d1 d1 d1
d2 d2 d2
d3 d3 d3
the problem is, i dont know how can i maintain spaces between the
columns as i dont know which column will have what length of text.
in c++, i think u can do by adding padding to make sure the alignment
remains correctly but i dont know how can i do that in c#.
i would appriciate your help,
thanks
Lucky Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105876
How to store additional information in a DataGridViewComboBoxColumn column?
.NETTers,
My table for customer information contains CustomerName and CustomerID.
In the datagridview, I am using DataGridViewComboBoxColumn to display
the list of customers.
When the user selects a customer, the corresponding cell gets filled
with the name of the customer.
However, in this process, I seem to be losing the customer ID. In my
application, the name of the customer is only for display purposes.
When OK is hit on the main Windows form, I need the actual customer ID.
When the user selects the customer name in the combo box, I somehow
need to retrieve the associated customerID and tag it to the current
data grid row.
This seems like a simple requirement. Is there a simple way to achieve
this?
I am trying to use standard datagrid functionality as much as possible.
Thank you in advance for your help.
Pradeep Tag: Allitcertkiller.com study guides are cheaper than Testking.co.uk guides Tag: 105874
Allitcertkiller.com study guides are cheaper than Testking.co.uk guides