Databinding and saving changes (if any) to new row
Hi there!
I am new to databinding in .Net and I think I am going to get crazy...
What I need to do is this:
1) Create a new form for the user to enter a new Product
2) Save changes (if any) when the user closes the form
But I still couldn't get what I want, even after searching in Google.
Anyone can give me a pointer/hint?
Here is the details:
1) The form FormProduct (in which textboxes are bound) gets loaded:
private void FormProduct_Load(object sender, System.EventArgs e)
{
cmProduct = (CurrencyManager)BindingContext[dsProduct,"Products"];
LoadData();
cmProduct.AddNew();
}
2) Users either enter something or just close the form
3) Before closing the form, save any changes (I am stuck here):
private void FormProduct_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
cmProduct.EndCurrentEdit(); // Saw this in several places already
if(dsProduct.HasChanges())
SaveData();
}
The problem is this:
if I don't call cmProduct.EndCurrentEdit(), then changes will not be
detected.
But if the user hasn't entered anything, they just close the form (like
a cancel), dsProduct.HasChanges() will return true (because we added a
row in the dataset).
Any solution? Tag: Get the answers! (Dutch) Tag: 88219
Bastardized TabControl
Greetings,
I was wondering if anyone knows if the following implementation of
TabControl exists out there.
TabControl would have 2 sets of tab pages. Both sets are aligned at the
top of TabControl, only the first set is aligned at the top-left corner
and the second - top-right.
Regards. Tag: Get the answers! (Dutch) Tag: 88218
dataGrid - Detect new row being added and prefil columns with data
I want to detect when a new row is added to my datagrid.
At that time I want to fill all the columns with some initial values
before the user gets to start editing them.
These values are not always the same, they will dpeend on who is using
the program at the time, the machine they are on and variuos other
factors.
Because of this I cannot use the solution that assigns default values
to all columns
Any ideas?
RichardF Tag: Get the answers! (Dutch) Tag: 88211
Don't use the object: ActiveForm unless you check it for null each
Don't use the object: ActiveForm unless you check it for null each time you do.
This object is in my opinion flawed and not all that useful since it becomes
null when the form loses focus. I am posting this warning lest you too fall
into the trap of using the ActiveForm.refresh() method instead of the
tnis.refresh(); method.
They are not the same and you may or maynot find your program crashing
because you did not first check each time you call the refresh method
associated with the object again try not to use ActiveForm object and instead
use the this object of the form or the actual form itself.
I think this is a bad design for ActiveForm object. Bottom line is do not
use it unless you are absolutely forced to. Instead use the this.object
Here is the original error message I ultimately solved:
System.NullReferenceException: Object reference not set to an instance of an
object Tag: Get the answers! (Dutch) Tag: 88209
ANN: Advanced auto-layout panels plus XAML-style interpreter for 1.1
We have released a library containing a couple of automatic layout
controls targetted at .Net 1.1 similar to the the FlowLayoutPanel and
TableLayoutPanel in Avalon. Also packaged with these are a basic
XAML-style interpreter which works well with existing Windows.Forms
controls.
These are useful for:
- creating resolution-independent applications (especially for those
who are long-sighted)
- internationalisation (automatic static text translation included in
the interpreter)
- allowing you to create central visual style rules for an application
via XSLT processing of XML script files.
Find out more at http://www.regulussystems.com/VersaForms Tag: Get the answers! (Dutch) Tag: 88208
Creating a localized control
In my application, I am providing a plugin capability by using an interface
to specify what the plugin should do. One of the functions is
'CreateConfigurationControl' which returns a UserControl.
I am now trying to localize the application, and I'm setting the
Thread.CurrentThread.CurrentCulture and CurrentUICulture objects as the
very first thing in my Main(). The forms that are created normally are all
appearing as their localized versions, but the control that I receive from
the CreateConfigurationControl is not, even though there is a localized
version defined.
In order to actually create the control, I've tried a simple 'new
ConfigControl()' and Activator.CreateInstance, passing
Thread.CurrentThread.CurrentUICulture to the appropriate version of
CreateInstance(Type, BindingFlags, Binder, object[], CultureInfo), but I
still get back the default English version...
Any suggestions on what I might be doing wrong, or if there is an easier
way to guarantee that I get back the correct localized version of my
control?
-mdb Tag: Get the answers! (Dutch) Tag: 88203
MeasureString() and ClearType
Hi all,
When I draw a string with TextRenderingHint.ClearTypeGridFit the width
of the drawn string is wider than what is returned by MeasureString. I
had hoped that setting the TextRenderingHint prior to calling
MeasureString would solve this, but it did not.
Any ideas on how to get the actual width of the drawn string when using
ClearType?
Thanks,
Cole Tag: Get the answers! (Dutch) Tag: 88200
Login windows -> Child form, strange behaviour on minimize
Hi all,
I've got a typical windows form application with a login form, when I
login, the login form will be hidden and a new window will appear.
For this, I'm using .Show() method, and not .ShowDialog() because
there's a chance of reloading a different ini file during login and I
want to allow the user to reuse the login form (and it's credentials),
and when the user reloads the login form will became visible and the
the other window will became hidden.
If he really tries to login again then I will kill the new window and
create a new one.
This all works fine, the problem happens when I try to minimize the
login form, a small box appears in the left corner just like a mdi
window when we minimize it on the main form.
I would like for this "box" not to appear, and the form simply
disapears and when I press the on the icon of the taskbar the window
would appear again, just like any windows form application.
Any help?
Thanks,
Luis Miguel Pinho Tag: Get the answers! (Dutch) Tag: 88197
How do I close an OpenFileDialog window from outside the window?
I have an application that is displaying an open file dialog window:
System.Windows.Forms.OpenFileDialog myDialog = new OpenFileDialog()
DialogResult myResult = myDialog.ShowWindow(this)
After a timeout, I want to close this dialog (basically, if the user does
nothing for a period of time, I want the dialog to close).
I have created the timer which fires at the appropriate time but I am having
difficulty finding out how to close the dialog once I receive the message.
Any suggestions appreciated. Tag: Get the answers! (Dutch) Tag: 88196
Add image to a control...reposted from languages.vb
I originally asked this in languages.vb, and someone there suggested I post
it here instead.
The requirement I've been tasked with is to have a textbox that has an image
in it (a magnifying glass) always on the right side of the textbox, but
still in the edit portion. The image should be BEHIND the text, and if
clicked on then would fire an event.
The suggestion I got from the other group (Carlos J. Quintero, the
illustrious maker of MZ-Tools) was to make it an ownerdrawn textbox. He
said that all I'd probably need to care about would be the paint event and
the click event. In VB6 I'd subclass the textbox and watch for the WM_PAINT
message, but in .Net I have NO idea where to start on this.
Can someone point me in the right direction?
Thanks.
Matt Tag: Get the answers! (Dutch) Tag: 88195
changing the height of a columnheader in datagrids
hi
I would like to change the height of the columnheaders on a datagrid.
this is to accommodate a multiple line header title.
example:
___________
Appointment |
time |
---------------|
also to override the columnheader text alignment so that it doesn't cause
the datagrid textbox (cells)to have the same Text Alignment
Thanks Al Tag: Get the answers! (Dutch) Tag: 88189
Localization question
I'm writing an application that needs to be localized into German. I've
set the Localizable to 'true' and the language to 'German' on my form.
I've translated all of my controls.
However, I have a UserControl on my form (which I have also localized to
German) but the designer still shows it in English. I have recompiled so I
know that the designer should know about the localized version of the
UserControl.
Is this the expected behavior, or should I see the localized German version
of my UserControl as well?
Also, is there any way I can specify on startup what language I want to
use? I'd like to run my program in "German mode" to make sure I haven't
missed anything.
Thanks!
-mdb Tag: Get the answers! (Dutch) Tag: 88188
RichTextBox - beeping
I am programatically adding blocks of text to a RichTextBox control and it
constantly "beeps" when doing so. The program is reading an xml file line by
line and when it finds certain attributes it changes their values to a
different color. This means that a line of xml might have its color changed
several times. I thought it had to do with the changing colors but when i
commented that code out it still beeped. If i write the entire line without
substringing it together i get no beeps. It only seems to happen when i
break the line up and substring it back together.
example:
the True part will beep but the false part will not. Color changing has been
omitted since it's not a factor.
if (true)
{
rtb1.SelectedText = line.Substring(0,10); // originally set color to
black
rtb1.SelectedText = line.Substring(11,10); // changed color to red
rtb1.SelectedText = line.Substring(21,10) + "\r\n"; // changed back to
black
}
else
{
rtb1.SelectedText = line + "\r\n";
}
Anyone know why this happens and is there a way to stop it?
Thanks,
David Tag: Get the answers! (Dutch) Tag: 88186
Multithreaded WinForms question
My application's form is handling an event raised from a worker thread in
another object. In the event handler I want to call a sub procedure that
does a number of things and among those things is accessing controls on
the form. This sub procedure normally has been called from the Click
event procedure of a button on the form so there haven't been any issues
with accessing controls from outside the UI thread. Now I have to
consider this.
I could create delegates for all the procedures I need to Invoke on the
controls but I was hoping there was a simpler way. Is there any way to
force the UI thread to call a sub procedure without using Control.Invoke
()? For example:
Private myObj As MyObject
Private Sub MainForm_Load ...
...
AddHandler myObj.SomeEvent, AddressOf MyObject_SomeEvent
...
End Sub
Private Sub MyObject_SomeEvent(ByVal whatever As Integer)
' SomeEvent is raised by a worker thread in MyObject.
' How can I force the UI thread to call SomeProcedure
' from here so I don't have to litter the SomeProcedure
' Sub with If...Then...Else structures testing
' Control.InvokeRequired() and calling Control.Invoke()
' with various custom Delegates that I have to create?
End Sub
Private Sub SomeProcedure(ByVal whatever As Integer)
... Do Stuff
SomeTextBox.Text = "Gooney Goo Goo"
...
End Sub
Hopefully I'm making sense here. I may be a little confused and not
realize it yet.
Joel Moore Tag: Get the answers! (Dutch) Tag: 88185
custom objects in clipboard
Hi,
I am trying to put my custom object in the Clipboard but when I try to
retrive, I get "Nothing".
Let me show you how I am doing this,
' putting data into the clipboard
Dim dataObj As New System.Windows.Forms.DataObject
dataObj.SetData(System.Windows.Forms.DataFormats.GetFormat("MyClass").Name,
False, objOfMyClass)
System.Windows.Forms.Clipboard.SetDataObject(dataObj)
' retrieving from clipboard
Dim dtObj As System.windows.forms.IDataObject =
System.Windows.Forms.Clipboard.GetDataObject()
If
dtObj.GetDataPresent(System.Windows.Forms.DataFormats.GetFormat("MyClass").Name)
Then
objOfMyClass =
CType(dtObj.GetData(System.Windows.Forms.DataFormats.GetFormat("MyClass").Name,
False), MyClass)
End If
I am getting "True" from the following command
dtObj.GetDataPresent(System.Windows.Forms.DataFormats.GetFormat("MyClass").Name
But "Nothing" from the following one
dtObj.GetData(System.Windows.Forms.DataFormats.GetFormat("MyClass").Name,
False)
Please give your suggestions how can I fix it.
Regards,
Naeem Tag: Get the answers! (Dutch) Tag: 88182
Control OnMouseDown and OnMouseUp called twice - surely a bug?
I'm noticing strange behaviour with System.Windows.Forms.Control.
If I press the mouse (left button), then move the mouse while still holding
it down, and then release the mouse, I get an extra set of OnMouseDown and
OnMouseUp.
So I get OnMouseDown, OnMouseUp, OnMouseDown, OnMouseUp even though the
mouse has only been pressed and released once.
Does anyone know about this? I think this is surely a bug. It's easy to
replicate. Add this code to a new user control and put an instance of the
control on a form.
Protected Overrides Sub OnMouseDown(ByVal e As
System.Windows.Forms.MouseEventArgs)
Debug.WriteLine("OnMouseDown")
MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As
System.Windows.Forms.MouseEventArgs)
Debug.WriteLine("OnMouseUp")
MyBase.OnMouseUp(e)
End Sub
You might have to try a few times to see it, but it usually only takes a few
efforts. It seems easier to replicate if I drag the mouse from the bottom of
the control towards the top!
Thanks in advance. Tag: Get the answers! (Dutch) Tag: 88181
DateTime picker control
Hi,
How can I set the background color of DateTime picker control when its
disabled.
Regards,
Naeem Tag: Get the answers! (Dutch) Tag: 88179
reply(how to get the textvalue from checkedlistbox)
(Type your message here)
just saw your problem try this
ChkListSupplementaryCode is the name of the checkedlistbox
For i = 0 To ChkListSupplementaryCode.Items.Count - 1
MessageBox.Show(ChkListSupplementaryCode.GetItemText(ChkListSupplementaryCode.Items.Item(i)))
Next
--------------------------------
From: thariq Sulaiman
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>iBM7QrjyO024qDXhi66XWQ==</Id> Tag: Get the answers! (Dutch) Tag: 88176
Application does not shut down even after Application.Exit
Hi
I am facing a weird problem with Application.Exit in Windows 2003 (No
Service Packs). After this statement is executed, the application does
not go down and CPU usage goes up to 100. This problem occurs only in
Windows 2003. Windows XP (SP2 and SP1) are just fine.
Does this have any thing to do with COM Interop or license of
components? I have a VB6 OCX control and ComponentOne True DBGrid.
Any help would be greatly appreciated.
Thanks and Regards
Prasanth Tag: Get the answers! (Dutch) Tag: 88169
Modeless Form visibible but inivisible PLEASE PLEASE HELP
Hi,
We have an application which contains numerous ChartFX controls. Basically the user can double click on an existing chart, and it will open a new (modeless) form which contains a new chart.
The problem is that the new window although appearing to be the focussed window isn't, as the user has to click on it twice (one click seems to be passing right through to the parent form) before the window is actually selected.
This wouldnt be such a big problem except that if the user right clicks on the chart we get a "Cannot display context menu on invisible control" error, even though the control is visible.
I guess that basically somehow the modeless dialogue window is not visible to the underlying code, and the events arent firing properly.
I have tried everything I can think of to fix it including calling Select(),Activate(),BringToFront() etc on the new window but none of them make any difference. I have even triggered mouse events on the new window to try to focus it automatically.
I am pretty much desparate to make this work so Can anyone please help me?
Thanks,
David
--------------------------------
From: David Brooks
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>OnD6s6O1MEaz/WOzww1bkA==</Id> Tag: Get the answers! (Dutch) Tag: 88157
Administrating the registry
Hello,
How can I programmatically set user rights to a particular registry key? Is
this possible? All I have found so far is checkaccess to see if I can access
a key. For instance, If I want to set the ASPnet account to read only on a
registry key HKEY_LOCALMACHINE\software\mystuff\ ? Tag: Get the answers! (Dutch) Tag: 88156
Screen.WorkingArea Changed Event?
Hi all,
First the question:
Is there a way to be notified when the WorkingArea of the Screen
changes? (for example, the taskbar is moved from bottom to left of
desktop)
Here are the details of the problem if you are interested.
I have a form where I set the Region property. Everything works fine
until you move the TaskBar to the left or top of the desktop. This
then skews my Region's location and it appears incorrectly.
The problem is caused when I translate my Region to the screen
coordinates (using PointToScreen and Region.Translate). If the taskbar
is on the left or top, the region gets "pushed" to the right or bottom.
However, this position is incorrect. I solved the issue by offsetting
the region location using Screen.WorkingArea's x and y values.
Then I ran into a performance problem. I have to recalculate the
region quite a bit and it caused a performance issue. I was using
Screen.FromControl() everytime I was recalculating the region (My
application must support multiple monitors) and I believe this was the
culprit.
I have worked around the issue by caching the working area myself and
testing if my Form moves from one monitor to the other via the
LocationChanged event.
The only problem is I need to know when the WorkingArea changes so I
can update my cached workingArea and also re-translate my region.
TIA
Cole Tag: Get the answers! (Dutch) Tag: 88151
(newbie) Slow Combobox Binding
I'm fairly new to winforms, but I've been playing around with ASP.NET for a
while, so I'm familiar with a fair bit of the framework, however I'm having
an annoying issue when trying to bind a simple arraylist to a combobox.
All I want the combobox to be is a simple dropdownlist and I'll grab the
SelectedValue from it to do other stuff elsewhere, so what I thought I could
do is :
myCombo.DataSource = myArrayList;
myCombo.DisplayMember = "Name";
myCombo.ValueMember = "ID";
Where myArrayList is an ArrayList (shock!) of simple objects with the
properties "Name"(string) and "ID"(int).
(very basically, their class definition is just :
public class myClass
{
myClass() {}
myClass(int ID, string Name) { this.Name = Name; this.ID = ID; }
public string Name;
public int ID;
}
- it's not quite that dumb, but you get the idea)
I'm finding that not only is DisplayMember *completely ignored* (i.e. all
the entries in the combobox merely display "myNamespace.myClass"), but the
binding process seems to take an inordinately long amount of time -
somewhere up to 5 seconds. I thought initially it was a database access time
or the size of the ArrayList slowing it down, but I actually reduced it to :
ArrayList myArrayList= new ArrayList();
myArrayList.Add(new myClass(1, "First"));
myArrayList.Add(new myClass(2, "Second"));
myCombo.DataSource = myArrayList;
myCombo.DisplayMember = "Name";
myCombo.ValueMember = "ID";
and it still takes seconds!
Can anyone shed any light on this?
thanks in advance,
--
jo inferis Tag: Get the answers! (Dutch) Tag: 88150
How to set the max row number in the datagrid.
I use the datagrid to let the user edit the data in a table, say 6 row, 8
column,
but I don't want the user hits enter at row 6 and the datagrid automatically
append
a new row on the datagrid (view). How can I set the max row limit? Also, I
don't know if all of you have noticed, when you add just one row to a
datatable and display it in the datagrid, you will see your data in the first
row and a blank in the second row. Is there a way of just show one row of
data but not additional blank?
Thank you.
lz Tag: Get the answers! (Dutch) Tag: 88148
GDI resource leaks: Calling Dispose after ShowDialog
I am fighting exhausted resources in a large application with many
forms. It manifests itself by EVENTUALLY not being able to load an
ImageList. In researching this I see advice in previous postings to call
Dispose on a form when finished with the object, after a ShowDialog. It
is suggested this is necessary to avoid GDI resource leaks.
My question is, what about when you open the form non-modally with Show?
Will the form do its own Dispose, or am I obligated to find a way for
this to happen? If so, can someone suggest a strategy for managing this?
- Lee Tag: Get the answers! (Dutch) Tag: 88142
When opening a form: Failed to load ImageList
When opening a non-modal dialog form which has an ImageList that I use
for a Treeview, the program crashes. This does not occur consistently,
but certainly often enough to be very annoying. It has happened two days
in a row now for one user.
The exception trace suggests to me that the .NET Framework is attempting
to extract the bitmaps from the DLL resources, or such?
It appears to be happening before any user code is being called. I have
seen others report this problem, but never a resolution. It would seem
to be a Framework bug to me. But maybe there is something I am doing?
Any clue why this could be happening, or more importantly, what I can do
about it?
************** Exception Text **************
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.InvalidOperationException:
Failed to load ImageList.
at System.Windows.Forms.ImageListStreamer..ctor(SerializationInfo
info, StreamingContext context)
--- End of inner exception stack trace ---
at
System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object
target, SerializationInfo info, StreamingContext context)
at
System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object
obj, SerializationInfo info, StreamingContext context)
at
System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder
holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream)
at System.Resources.ResourceReader.LoadObject(Int32 pos)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean
ignoreCase)
at System.Resources.ResourceManager.GetObject(String name,
CultureInfo culture)
at System.Resources.ResourceManager.GetObject(String name)
at PPSManager.frmVolumeNavigator.InitializeComponent()
at PPSManager.frmVolumeNavigator..ctor()
at PPSManager.frmMain.PrintVolumeNavaigator(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam) Tag: Get the answers! (Dutch) Tag: 88140
Cancel Load-event
How is it possible to cancel the Load Event of a form?
I do some tests in the Load event and if they fail a message box should be
shown, and the form should never be shown?
How to code?
Best regards
Benjamin
SWEDEN Tag: Get the answers! (Dutch) Tag: 88139
A Newbie Question
Hi All,
I'm trying to develop a prototype for a small Room Booking application. This
is a 3 tier application. The presentation layer consists of Windows Forms.
There will be multiple concurrent clients. The application needs transaction
supportivity.I thought of developing in .NET C#. The data base is going to
be SQL Server 2000.
I thought of following the design guidelines mentioned in the
MSDN,Application Architecture for .NET Designing Applications and Services
from Microsoft
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html
/distapp.asp).
I have some questions. For my distributed application which technology would
be best suitable?. Enterprise Services COM+ components or .NET remoting or
Web Services? How can I take the decision? My application needs quick
response (Speed is important).
Thanks in advance.
Regards,
Risath Tag: Get the answers! (Dutch) Tag: 88131
Please help - how to call a web link in a windows form...
Dear Experts,
I am asked to develop a Windows Application that calls to a given web link
(e.g. http://localhost/Test.aspx?id=1234) and catches the returned HTML from
this link (returned from web server of course). I really have no idea on how
to accomplish this. Could you please give me some hints on resolving this or
please indicate any resources/references that I can refer to?
Thanks a lot for your help.
Tigger
--
I am Tigger. Tag: Get the answers! (Dutch) Tag: 88128
large forms slow in designer
For a while now I've been writing a point-of-sale application that has many
tab pages each with lots of components. The designer is getting very slow
at loading it, i'm wondering if there are any recommended practices for
splitting up the tab pages? I was able to make each page its own control
and although it spead things up a bit, its a pretty lame approach. What do
all of you do when you have forms with hundreds of components on different
pages? thanks.
Lloyd
SLOW30 Tag: Get the answers! (Dutch) Tag: 88106
Where can I see my logs?
I am developing a c++ application using windows forms. I have added to
it some classes I had developed for a console application. They compile
and run well, but I don't know where I can see the logs (which would
give me essential information!) that those classes write using cout.
Are they collected somewhere so that I can read them? Where does cout
write now if anywhere at all?
Thanks Tag: Get the answers! (Dutch) Tag: 88104
C# Windows Forms - GDI Leaks
Hi All,
I'm a bit new to the windows forms world, about 95% of my work is
service related, I usualy make console applications, no graphic
interface, the maximum interaction with client is "Press X to stop
application".
Now, in the windows forms world my application gets bigger and bigger
whenever I open and close a window (I'm making a MDI application)
What I mean is, the number of GDI objects, the number of handles
raises, the VM memory, what must I do? Should .NET framework take care
of disposing all the graphic object no longer in use?
If not, what can I do to prevent this?
In my company we use Rational Purify to search for mem leaks in C++ or
C can I use it to check leaks in C#?
Thanks for all the help you can give me,
Luis Pinho Tag: Get the answers! (Dutch) Tag: 88102
Question about Infragistics Grid and combo box
I am using an Infragistics grid and combo box. I have a table of
information that I would like to edit that has a foreign key in it. I
would like to show the user friendly description in the grid, then when
the user clicks on the grid, the the value can be changed through the
combo box. This combo is not one of the in grid combos, it is a
seperate one on the form. One of my requirements for these data entry
forms is that in-grid editing of data is not allowed. What is the
easiest way of doing this. Most of the examples that I have seen are
geared toward the in-grid combo box, not a seperate one elsewhere on
the form. Tag: Get the answers! (Dutch) Tag: 88098
I can't modify a MaskedTextBox control in binding.
I do not succeed to modify the content of a MaskedTextBox control
whose Property "OutputText" is in binding with field of type text of
one table in database a MDB. The control has been generated making a
drag-and-drop of the respective field from the window of the "Data Sources"
of the plan and associating to same a control of the
MaskedTextBox type to whose property "Mask" has been assigned the
following string "00.00.00" (to represent a time).
Only if i not set this property, I can to modify of the value, but
in this way I do not formatting automatic input of
the customer. From the same control, I want to be able to visualize
the value of the field and to only modify of the value (in sure
conditions).
The development environment is Visual Basic .Net Express with Framework
2,0 Beta.
Councils are accepted,
Thanks, dumbo. Tag: Get the answers! (Dutch) Tag: 88095
AutoScale Doesn't Behave How I Expect/Hope
I have just been playing with AutoScale and I am unhappy with the way it
appears to work.
I have a form created on a desktop m/c where the screen font is Normal (96
dpi). The form looks fine at design time and runtime. I run the application
on my laptop, where the screen font is set to 120 dpi (125%), and the form
does not look fine. The line height of a listbox on the form is too small,
labels are truncated, and things generally look cramped. AutoScale is set to
True.
I notice that when I open the designer on the desktop, the AutoScaleBaseSize
is (5, 13). When I open the designer on the laptop it is also (5,13). If I
then change the AutoScale property in the properties window and look again
at AutoScaleBaseSize, it has changed to (6,15). Now when I run the
application on the laptop all is well. Well, almost. I should point out that
user controls on the form still do not scale correctly, and since they do
not have an AutoScale property, all I can think of doing is calling the
Scale() method with a parameter of 1.25. The problem with this approach is
that I would have to do this for every user control, and there are a lot of
them. It doesn't seem right that I have to add special code to all my user
controls to get them to scale properly. Furthermore, I haven't discovered
(yet) how to determine the correct scale factor at runtime.
I thought that the point of the AutoScale property was that a form would
display correctly on m/cs with different display settings, without having to
rebuild on that m/c. It doesn't look like that is what really happens.
Have I missed out a step here? Does anyone know the correct procedure for
making this work?
TIA
Charles Tag: Get the answers! (Dutch) Tag: 88093
Using a Web Browser Control on Windows Forms to display Web Archive (*.mht) File
Folks,
I'm trying to somehow manage to get the standard IE web browser
control, hosted on a WinForm, to understand and display a "web
archive" file (mywebarchive.mht) as saved by MS IE 6 (Save As - File
Type: Web Archive (*.mht)).
No luck so far - seems odd, since MS IE can produce and display those
files just fine! What am I missing??
Thanks!
Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch Tag: Get the answers! (Dutch) Tag: 88092
Replicating Treeview
(Type your message here)
I have two treeview and i want when any node is added in one node=
it must be automatically added to the other treeview=2E
I was trying to override the Add method of treeview as well as=
treenode in a class, but both the functions are in property=
Nodes, so i was try to make a new method to do that ADD which=
will accept the Treenode and the other Tree Control in to Which=
the relicate of the original treeview is to be build , but i m=
facing the problem when adding a particular node to the selected=
node it gives me the Exception of type cast invalid from=
myTreenode to Treenode=2E
Can anybody suggest me a possible solution for replicating the=
Treenodes in two or more than two Treeview having same=
property=2E
--------------------------------
From: kanika Gauba
-----------------------
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
<Id>vlgHaK8sqku3+beb7vki9A=3D=3D</Id> Tag: Get the answers! (Dutch) Tag: 88089
Replicating Treeview
(Type your message here)
I have two treeview and i want when any node is added in one node=
it must be automatically added to the other treeview=2E
I was trying to override the Add method of treeview as well as=
treenode in a class, but both the functions are in property=
Nodes, so i was try to make a new method to do that ADD which=
will accept the Treenode and the other Tree Control in to Which=
the relicate of the original treeview is to be build , but i m=
facing the problem when adding a particular node to the selected=
node it gives me the Exception of type cast invalid from=
myTreenode to Treenode=2E
Can anybody suggest me a possible solution for replicating the=
Treenodes in two or more than two Treeview having same=
property=2E
--------------------------------
From: kanika Gauba
-----------------------
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
<Id>LVMH0fEBCEWtmViGj3x1UQ=3D=3D</Id> Tag: Get the answers! (Dutch) Tag: 88088
reportViewer in VS 2005
Where can I find some information about reportViewer control from VS 2005
Beta2 ?
I can't figure out how to use it.
Thank's Tag: Get the answers! (Dutch) Tag: 88086
duplicate the FileWebRequest Class
HI,
newbie here..
What i want to do sounds very simple, but i am having a hard time getting
the terms down so that i can even explain what i want to do.
In any web browser where my client app is running, if there is a URL like
"test://" or "dosomething://" that is clicked, i want my client app to catch
that and do stuff.
Please someone point me in the right direction.
I have tried building an activex control but it dosnt support the DDE
commands i want to use. I know that .Net dosnt either, but i am going around
the whole DDE part in the long run. what i have is a phone applicaiton, i am
integrating a web site with some of the parts of the phone app. when a phone
number is displayed on my web app, it will have a hyperlink on like <'a
href="call://201-555-1212">201-555-1212</a> This was my way of linking the
two apps together (the call:// part)
the phone app supports DDE, i have found a few free ocx's that will be my
DDE client and server parts. But iam not worried about that for now. I just
want to be able to pop up my client app when a link is clicked in IE and pass
my app some variables.
Thanks for any advise
Tim Tag: Get the answers! (Dutch) Tag: 88085
How to build moveable toolbar?
SGksDQoNCkknbSB1c2luZyBDIyBpbiBWUyAuTmV0IDIwMDMuIEhvdyBjYW4gSSBidWlsZCBtb3Zh
YmxlIHRvb2xiYXJzIGFzIHRoYXQgaW4gVlMgSURFLCBkcmFnZ2luZyBhbmQgYXJyYW5naW5nIHRo
ZW0/ICBNb3JlLCBob3cgY2FuIHRoZSBtb3ZlYWJsZSB0b29sYmFyIGJlIHB1dCBpbnRvIHRoZSBz
YW1lIGxpbmUgb2YgTWVudSwgYXMgdGhhdCBpbiBJRS4NCg0KQ2FuIGFueW9uZSBpbnRyb2R1Y2Ug
c29tZSBhcnRpY2xlcyBvciBzb3VyY2UgY29kZXM/ICBUaGFua3MuDQoNCi0tIA0KIkZvcndhcmQg
R2FsYXhpYSI= Tag: Get the answers! (Dutch) Tag: 88082
GroupBox...
hi:
is there a way to trigger a contextMenu when right-clicking on the
groupBox text title?
thanks... Tag: Get the answers! (Dutch) Tag: 88081
New Form Goes Behind Main Form when clicked.
I have a main form and from it i am creating and showing a new form using
the Show method. The form does not have an owner.
It correctly appears on top of the main form but when i click it it goes
behind the main form. If I then go bring the form to the front
it is fine from that point forward. It is just the initial click after
creation.
I believe I have done what I describe here successfully in several apps
before but I cannot figure out what is wrong here. Does anyone have any
thoughts? Tag: Get the answers! (Dutch) Tag: 88080
Problem Creating Handle
I have a UserControl that contains a few ComboBoxes and TextBoxes. For most
of the Controls/Forms that I drop this on, I'm not having any problems at
all. One form, however, is giving me problems and it seems to be crashing in
the CreateHandle method. I have put a breakpoint in the HandleCreated event
of my UserControl, but it's never hitting it cuz it crashes before that. It's
obviously having a problem creating the handle and I'm trying to figure out
why.
Does anybody know what event fires prior to the HandleCreated event? If I
can set a breakpoint there maybe I can figure out what the problem is.
TIA,
~~Bonnie Tag: Get the answers! (Dutch) Tag: 88079
How Best to Move From Form to Form
I've been a Web Developer for about 5 years, but am now being asked to write
a Forms based application. My basic question is how best to move from form
to form. I've read about MDI, ShowDialog, Form.Show(), and even just setting
various forms from Visible = True to Visible = False. I guess, I'm a bit
confused as to which would be the best implementation.
Just to give a few details on my project...
I will have a login screen, then once the user logs in I will have a main
screen. Depending on the options selected on the main screen, the user will
either be directed to a Delete Screen or a Copy Screen. The Delete Screen
and the Copy screen really do nothing more than inform the user of actions
taking place in a database. Basically just a logging/status screen. I know
I'll need to implement threading for this, but I'm not sure how best to move
from screen to screen.
Thanks. Tag: Get the answers! (Dutch) Tag: 88075
Some (not so?) general questions...
Hi all.
I'm primarly a C++ developer but I've been trying to complete development on
a C# application with the following basic requirements:
- The app runs in the background is initially hidden from the user,
including the Windows Taskbar.
- The app needs to receive a registered Windows message
- The app needs to "register" its window handle with an unmanaged C++ dll so
that a WM_USER message can be sent back to the C# app's WndProc
- The app needs to display itself when receiving the WM_USER message, and
hide itself after being acted upon by the user.
I ran into some problems along the way and wondered if anyone could provide
some feedback or comments. Especially since I told my project guy this
should be trivial to do in C#, and now I'm wondering if I made the correct
decision. I'm not looking good at this point.
1) In order to hide the app from the Taskbar, the main form's ShowInTaskbar
property would be set to "false", easy right? That action, however, (using
SPY++)removes the WS_APPLICATION style bit and prevents the application from
receiving any registered Windows messages.
2) I initially call a C#-to-C++ wrapper function to give my ".Handle" to the
unmanaged dll. This works for the first time, but when I set the main form's
Visible property to false and minimize the form, "Handle" gets a new value.
Is there some other "handle" I should be using? I work around this by
"re-registering" with the unmanaged dll after minimizing but there have been
a couple of occasions where a zero has been logged. Using FindWindow() in
the unmanaged dll would be acceptable, is there a way to "register a unique
window class"? The window titlebar includes message specific data so the
title changes.
3) I have seen several instances where the main window was shown (Visible =
true), but with no controls on it. Using SPY++, I see the main window listed
with no child controls, and a "WindowsFormsParkingWindow" which contains all
the children for this form. The data on the controls is correct, but it's as
if they are just not on the right form.
4) I also intended for a Windows Service to start the application, which
works, but the application does not survive a user logoff. We have C++/MFC
applications which do a subclassing code trick to accomplish this but I've
not found an equivalent for C# apps.
http://support.microsoft.com/kb/q164166/
5) I have the main form's TopMost property set to true, and after 2 hrs. of
messing around, I discovered the tooltips are showing behind the form. This
is the case for XP as well as Win2k.
One unrelated thing:
1) Once in a while my VS.NET search function starts reporting something like
"no files found to search in". Strangely enough, when I press CTRL+SCROLL
LOCK it starts working again. Not a big deal once you know the trick.
I apologize if I've missed this information but I looked in the groups and
didn't see any real answers to these questions. I would greatly appreciate
any input as to whether some of this behavior falls in the category of
"that's just the way it is", or I'm not doing things correctly, or bugs to
be fixed, or need to look at workarounds. I'm using VS.NET 2003 and .NET
Framework v1.1 and the target OS is Win2k. Needless to say, I've been
frustrated to this point in creating what I "thought" to be a pretty simple
app. My fear (from a schedule standpoint) is that I have to start over in
C++. Thanks in advance for any comments or insults :- ).
- Brad Jones (not CodeGuru guy!) Tag: Get the answers! (Dutch) Tag: 88074
How to control the order in which individual child controls are rendered
Hello All,
I am creating an image browsing function within an application. As such, I
created a Thumbpanel control (shown below) which displays a collection of
thumbnails. Each thumbnail on that panel is also a custom control ( of a
class called Thumbnail) placed at a calculated location on the Thumbpanel.
It turns out to take 1+ seconds to construct and render each Thumbnail, so
in turn it takes MANY seconds to render the whole panel. Therefore I need
to force each Thumbnail to be rendered individually as they are constructed,
so that the user will not be confused by the frozen screen awaiting the
whole thing to render. I expected that the line:
thumb.Refresh();
... would force the thumb object (of type Thumbnail) to be rendered upon
that call. But that didn't do the job.
Can someone give my guidance on how to force rendering of the individual
child controls (Thumbnails) in the order I specify?
Thanks,
-- Bruce
-------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace WTMWClient
{
/// <summary>
/// Summary description for ThumbPanel.
/// </summary>
public class ThumbPanel : System.Windows.Forms.Control
{
Assets m_Assets;
ArrayList m_Thumbnails;
bool m_Scrollable = false;
public delegate void ThumbPanelDoubleClickedHandler(object sender,
ThumbnailDoubleClickedEventArgs e);
public event ThumbPanelDoubleClickedHandler
ThumbPanelDoubleClickedEvent;
private System.ComponentModel.Container components = null;
public ThumbPanel()
{
InitializeComponent();
m_Assets = new Assets(); // Simply a default value so it will not
be null.
m_Thumbnails = new ArrayList();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
~ThumbPanel()
{
// ~base();
foreach (Thumbnail thumb in m_Thumbnails)
{
thumb.Dispose();
}
}
#region Component 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()
{
//
// ThumbPanel
//
this.Dock = System.Windows.Forms.DockStyle.Fill;
}
#endregion
protected override void OnPaint(PaintEventArgs pe)
{
// TODO: Add custom paint code here
// Calling the base class OnPaint
base.OnPaint(pe);
}
protected override void OnResize(EventArgs e)
{
base.OnResize (e);
PlaceThumbnails( false );
}
/// <summary>
/// Place each thumbnail in its proper position. Assumption is that
/// each thumbnail has already be constructed and placed in the
/// m_Thumbnails collection before this call.
/// </summary>
protected void PlaceThumbnails( bool isFirstDrawOfThisSetOfThumnails )
{
// Remove all the old ones. (But, dont "dispose" them, since they
// are still instantiated and held in m_Thumbnails.)
this.Controls.Clear();
// Place each one in proper position....
int x, y;
x = y = 0;
if ( isFirstDrawOfThisSetOfThumnails )
{
m_Thumbnails.Clear();
Thumbnail thumb;
foreach (Asset asset in m_Assets)
{
thumb = new Thumbnail( asset );
m_Thumbnails.Add( thumb );
thumb.ThumbnailDoubleClickedEvent +=
new WTMWClient.Thumbnail.ThumbnailDoubleClickedHandler(
thumb_ThumbnailDoubleClickedEvent);
thumb.Location = new Point(x, y);
this.Controls.Add(thumb);
thumb.Refresh(); // I expected this to force rendering
here. No luck!!
x += thumb.Width;
if ( x > this.Width-thumb.Width )
{
x = 0;
y += thumb.Height;
}
}
}
else
{
// no need to instantiate individual Thumbnails in this case.
// Rather, just grab each from the m_Thumbnails collection.
foreach (Thumbnail thumb in m_Thumbnails)
{
thumb.Location = new Point(x, y);
this.Controls.Add(thumb);
x += thumb.Width;
if ( x > this.Width-thumb.Width )
{
x = 0;
y += thumb.Height;
}
thumb.Refresh();
}
}
}
/// <summary>
/// Assign an Assets collection to be spanned via a set of thumbnails
on the panel...
/// </summary>
public Assets AssetsSource
{
set
{
m_Assets = value;
if (m_Assets.Count == 0) return;
PlaceThumbnails( true );
}
} // Property: AssetsSource
protected void thumb_ThumbnailDoubleClickedEvent( object sender,
ThumbnailDoubleClickedEventArgs e)
{
// MessageBox.Show( "clicked on: " + e.Asset.FileName );
if ( ThumbPanelDoubleClickedEvent != null)
{
ThumbPanelDoubleClickedEvent( sender, e );
}
}
}
} Tag: Get the answers! (Dutch) Tag: 88072