|
Good day everybody
There are cases on a form when the user might create a new row for example and not complete all the mandatory information as imposed by the database. In other words if you forget to enter data in a textbox binded to a datacolumn that does not allow nulls.
In that case if the user leaves the row somehow a NoNullAllowedException will be thrown. My problem is I am not sure what is the best way to handle this.
I thaught i could c,apture an event on the BindinSource but there is no "PositionChanging" event there is just a PositionChanged event, which of course is too late.
I could also take care of the case in the form itself but it seems like a lot of code for something that could be so simple.
Any suggestions?
Very confused
|
|
|
|
|
If you were using a DataGridView you'd be able to use the DataError event (I think that's the name) to capture it. You may have to handle it manually on a 'Save' )by checking a value isn't null before committing to the DataSet / DB) if you're using your own custom GUI for editing rows.
|
|
|
|
|
Hi @all!
I've got an amazing problem... or better a driving me crazy problem...
i have this code in print event...
StringFormat strFormat = new StringFormat();
strFormat.Trimming = StringTrimming.None;
strFormat.FormatFlags = StringFormatFlags.NoClip;
RectangleF InfoRect = new RectangleF(curXPos, nCounter, (e.MarginBounds.Right - CurXPos), newFont.Height);
e.Graphics.DrawString("Hello World! Test Text", newFont, brush, InfoRect, strFormat);
as anyone can see: newFont is a Font var, brush a brush, InfoRect a RectangleF and strFormat the StringFormat...
Ok, the problem now is quite simple... or for me not:
if the Text doesn't fit to InfoRect it's wrapped to next line... my problem is, how do i calculate the height of the needed space - especially the height - if it's not wrapped it's no problem, but when it's wrapped, i don't know how to get the height - i need the height to be calculated before the text is drawn by DrawString !!! i draw a rectangle around my text... so i need to know the height before... any suggestions??? Thank you!!! All ideas are welcome...
Ralf
FreewareFire is in the House!
|
|
|
|
|
There is Graphics.MeasureString()
You should use it with the same arg list as Graphics.DrawString()
except that the bounding rect must be replaced by the rect's size
(since measurestring does not care about the location)
and it will return the rect size DrawString() would like to have.
Both know how to do word wrapping.
Normal usage would be: give it a rect with the available width and a very large height,
it will calculate the effective width and the required height; if you have sufficient
height available, then do DrawString with the original height and width and the text will fit.
If you have insufficient height, and call drawstring anyway only part of the text would be drawn.
Luc Pattyn
|
|
|
|
|
Well, it works! Damn, i've forget the strFormat at MeasureString-Line... *lol* - now it works fine! Many thanks to you Luc! - you gave me the solution!
Thanx a lot!
FreewareFire is in the House!
|
|
|
|
|
Hi Everyone
I'm doing a program where I want to play an audio file. In the mean while I want to do some audio processing in the background which in my case is quite CPU demanding. My concern is that I want be able to play music simultaneously and have to wait for the processing... so I was thinking if someone has some suggestions on how this can be done ...
Thanks in advance
Al
|
|
|
|
|
Hi,
have your calculations handled by a background thread running at a lower priority
(Priority.BelowNormal).
Luc Pattyn
|
|
|
|
|
Hi,
I created a small Windows app that displays variables values with Console.Writeline. It compiles correctly, but it displays a screen in less than half a second then I can't see the output. Why is this?
Regards,
ma se
|
|
|
|
|
You should prevent your app from terminating (and closing its console); typically this
is achieved by adding these two lines at the end of your main method:
Console.WriteLine("Hit enter key to terminate...");
Console.ReadLine();
Luc Pattyn
|
|
|
|
|
|
hello
I want to find this assembly file
how can I find it?
have anybody this file?
it is in microsoft embeded windowa
microsoft.pointofservice.dll
please help me to find
if u know, please tell me
my email is hamed_r81@yahoo.com
Masterhame
|
|
|
|
|
|
Hello,
I have a question regarding the crystal report. I have a program that will print custom bills and I use for that crystal report, the user can not view the report its only called to be printed.
The database connection used has a local path on my computer. How can I make it dynamic so I can use it on other computers as well?
Thanks.
Regards,
Butterfly
|
|
|
|
|
I simply created a Windows Control Library project in VS. I add 2 user control form. On one form there is only a button and the sencond user control form i add a text box. So let say i want to import only one of them in my another project how do i do this. I don't want to import or add reference for both user control.
Secondly when i looked at my usercontrol project debug directory it created a project dll. I want dll for specific one.
thanks
|
|
|
|
|
If the controls are in the same project you have no choice, you will get both as you are referencing the assembly, not the controls.
only two letters away from being an asset
|
|
|
|
|
Hello. I'm using VS 2005 and I have taken over a project that has images included in the resources of the project that are visible by going to the project's properties sheet and clicking on the 'Resources' tab. Is there a way I can update this while building? For instance, there's about 50 images in there now associated with 'Company 1'. I'd like to have it where I can use different images when I do a build, depending on whether COMPANY1 or COMPANY2 is defined for that build configuration. Even doing it dynamically at runtime depending on a registry setting or something if I could put the images in a .resx file and have the program use that instead of the ones in the 'Resources' tab.
Thanks in advance
|
|
|
|
|
Maybe what you need is 3 projects (1 dll and 2 exe):
1 dll with all or most of the code
1 exe for each company, including all the appropriate images and referencing the code dll.
Alternative:
You could create extra projects with an image-only dll for each company,
and keep all code in the single exe, which then dynamically loads the right image dll.
(search for "late binding" on CP).
Luc Pattyn
|
|
|
|
|
I think the alternative solution would be what I would like to go with. however, I still don't have a clue as to how to tell the .exe to use the image dll as opposed to using the images that are in 'Resources' on the properties page for the project.
|
|
|
|
|
Well, I have not done this myself, but this is how I understand it:
- you make a new project targetting a dll instead of an exe,
and you add your images to that project just as you did so far for your exe project
- in your existing exe project, you remove the images you currently have as resources;
and you add code to decide which image dll is required (assuming you did build more than
one image dll), you then load it dynamically, and then get the images from there.
For dynamic dll load, and how to get at its content, please search "late binding" on CP.
Come to think of it, there must be yet another alternative, based on internationalization;
this is an official mechanism to support alternate sets of resources, normally intended
to easily port your app to other languages/countries without changing the main code.
I guess you could use it to just substitute alternate sets of images (and maybe some strings,
such as company name).
This too I have never done, and it also involves extra dlls, so it is very similar (if not
identical) to what I described earlier. One possible difference is internationalization
also supports a "default" country/language, which can be built-in (i.e. when no country-specific
dlls are available or selected). More on this surely in the MS documentation.
-- modified at 14:22 Monday 29th January, 2007
Luc Pattyn
|
|
|
|
|
I used to do this to retrieve the data of the table cell through WebBrowser object in VB.
txtresult = WebBrowser0.Document.all.tags("Table")(TableNo).Rows(RowNo).Cells(ColNo).innertext
TableNo: the ordinal number of the table in HTML page.
How can i do the same thing in C#? I tried many ways but all i got is error
Can i get some help pls?
|
|
|
|
|
teeboss wrote: How can i do the same thing in C#? I tried many ways but all i got is error
Use [] brackets for indexer properties in C#
|
|
|
|
|
just change [] -> ()? And the code is:
txtResult.Text = WebBrowser0.Document.all.tags("Table")[TableNo].Rows[RowNo].Cells[ColNo].innertext
would it work? I recieved the error "no property..."
Can u explain in detail pls?
|
|
|
|
|
He told you all you need to know, in C# it's square brackets, any error you get now, is because the code is wrong.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have a datatable that contains 10 columns (Say they are called column1, column2, column3, etc).
I have a schema that contains column3 (meaning I only want to create an XML file containing this column).
How would I export only column3 from my datatable into an XML file based off a supplied schema file ?
Thanks
|
|
|
|
|
Dear all,
I've searched high and low to find an example of a way to preview and print a single panel. I found a few ( very expensive ) commercial libraries , but I don't want to go down that path. Is there anyone who could help me out , or at least point me in the right direction on how it's done.
Kind regards,
Rick
|
|
|
|