|
I have been working on a custom DataGridView which will be used in unbound mode. I have had a problem where, if the user edits a cell with text longer than allowed by the database, the text is truncated when it is saved back to the database.
The following OnCellValidating method is my attempt to validate the length of cell text. The idea is that if the new text is longer than allowed by the database, the cell changes its background color, a message is given and the user cannot proceed off the cell until valid data is provided. Here is the code:
1: Protected Overrides Sub OnCellValidating(ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs)
2: Dim Col As DataGridViewColumn = Me.Columns(e.ColumnIndex)
3: Dim FD As FieldDescriptor = TryCast(Col.Tag, FieldDescriptor)
4:
5: If Me.Rows(e.RowIndex).Cells(e.ColumnIndex) IsNot Nothing Then
6: Me.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.BackColor = Col.CellTemplate.Style.BackColor
7: End If
8:
9: If Col.ReadOnly OrElse _
10: (FD.DescriptionRow Is Nothing OrElse FD.DescriptionRow.ColumnMetadata Is Nothing) Then
11: Exit Sub
12: End If
13:
14: Dim CM As DbColumnInfo = FD.DescriptionRow.ColumnMetadata
15: Dim MaxSize As Integer = CM.MaxLength
16: If e.FormattedValue.ToString.Length > MaxSize Then
17: Me.Rows(e.RowIndex).Cells(e.ColumnIndex).Style.BackColor = ColorConstants.MissingData
18: Me.InvalidateCell(e.ColumnIndex, e.RowIndex)
19: ShowMsg(String.Format("This field is limited to {0} characters.", MaxSize), _
20: MsgBoxIcon.Critical, "Text is too long!")
21: e.Cancel = True
22: End If
23: End Sub
The class FieldDescriptor is filled in an earlier phase; its ColumnMetadata property holds a class with the column's metadata such as the varchar size. ShowMsg is a standard interface for providing feedback to the user in various application setups.
The problems I'm having are in trying to set the cell's style property. The change in the background color made in line 17 is never visible, even though I am calling InvalidateCell in the very next line. None of the other invalidate routines work, either. Worse, setting the cell's Style.BackGround property sets CellTemplate.Style.BackColor for the entire column, making my efforts to reset the cell's background to the default color in lines 5-7 pointless.
Ok, fine, use the ErrorText property. Problem is, if I use e.Cancel = True then the error icon is never rendered, leaving the user with no feedback as to which cell has the error. If I do not set the Cancel property, then error icon is rendered; however, the validation is considered good and the database update (along with the truncation of data) proceeds.
Any suggestions on how to proceed?
|
|
|
|
|
Hi all. I'm developing a solution which is designed to give the end-user a semi-customisable workflow solution where they can define the steps an item need to take through a workflow before it becomes "signed-off". There are several paths which an item can take, and several types of item which may enter the system. It's essentially a bug-tracker system with some bells and whistles on it. I'm wondering if WF is the technology to use. From browsing the documentation it seems as though there's a way to save the state of a workflow and not only that, it's possible to override the default implementation and write my own persistence layer. I'm at the stage where I need to commit to a platform with this, and I'd like some input from anyone who has used, or considered using, this option. Essentially what we're talking about is giving the user a very small subset of the functionality you get with using WF in Visual Studio. They don't need the works, there are fairly small custom parameters. And I need to make this happen fast, like in the next month.
Has anyone out there blooded themselves with a real-world WF project, and have they any input on this?
|
|
|
|
|
|
Hello everyone,
I'm a student of final yr telecom engg. For sometime now, I have been seeking advise/expertise in implementing customized voip applications, which is my project for the final semester.
I plan to develop a voip application which will basically be fielded on a LAN(i.e. no external VOIP provider). This voip network will comprise of a few clients(10 to 20) having either ipphone or analog phones with ATA, enabling voice communication among each other. In addition to this I want to develop a gateway which will be an interface between this network and an external network comprising of hand held radios. This gateway would facilitate voip calls between any client on the network to a hand-held radio operator.
I have a feeling that SIP would be an ideal choice, but I am not able to choose a platform for developing such an application. I have looked into Asterix(trixbox) which was advised to me by some friends...but frankly i am not very comfortable with Linux.
Is there something available in .NET or could any one advise any other platform?
Can anyone provide some help?
|
|
|
|
|
|
Hi,
On my form I have a Business EMail address field. I have a requirement where in the field should not allow any characters which are not valid in the EMail field of the Active Directory (AD).
Is any body aware of the email address regular expression which restricts user to enter any characters which are invalid in the email field of the AD?
Regards,
Vipul Mehta
|
|
|
|
|
A simple Google search [^]would have helped you
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I need to refresh the hardware device list in the Device Manager instead of doing manual rescan for the hardware changes by right clicking on any of the device and selecting the option for "Scan for hardware changes".
i need to do it using C# code.is there any way to invoke the setupapi.dll to perform the rescanning of all the hardware device in the Device manager list,
I need this because Non-PNP device will not be automatically detected by windows.
thanks and regards
vinayskvs
|
|
|
|
|
|
Thanks for this. It alerted me to the fact that SyncToy 2 has been out for almost a month.
Kevin
|
|
|
|
|
Hi buddies,
My gridview has some data which i want to spool in excel. For that i wrote a code in a button click event like this
protected void imbtnexcel_Click()
{
Response.ContentType = "application/vnd.ms-Excel";
Response.AddHeader("Content-Disposition", "inline;filename=ExcelRPT.xls");
}
im using VS2008.whereas this is working in VS2005
Here the event is getting fired but excel file is not opening.How to acheive this?
T.Balaji
|
|
|
|
|
Hello...
I have a service that basically handles threading. Each generated thread calls a WorkerClass in the Service project that in turn calls a new BaseClass project (dll) to do work. I have a boolean that I set in the WorkerClass which in turn updates the same boolean in the BaseClass project. The boolean simply indicates if the service is running or not running. My threads can take a while to complete (doing file reading, splitting, database reading, inserting, updating...etc...). When the OnStop function is called I want to update the thread in the BaseClass object to set the boolean (bServiceStoped) to true and immediately exit the BaseClass and end the thread. Does anyone know of a way to do this?
thanks...
|
|
|
|
|
|
This column would open a dialogbox when clicked
|
|
|
|
|
|
You can try adding image column from Columns->(Collection Properties)
and on the event of the datagrid click if the clicked column is the image column then you can can call a dialouge box to display.
|
|
|
|
|
What .NET reporting frameworks have you used and liked?
Most people do not like reports but we all know the business world needs them.
I have used ActiveReports for a little while now and noticed a steady decline in their release schedule.
Any suggestions?
|
|
|
|
|
|
SQL Server Reporting Services.
|
|
|
|
|
I'm responsible for a project involving development of a client-server application which requires two types of messaging between the client and the server:
1. Reliable message delivery to and from the server
2. Low latency, high volume data feed from the server to clients
With #1, I have found that MSMQ works pretty well for our needs within our network. However, I'm concerned that MSMQ doesn't work well over an untrusted network and therefore I am thinking of switching to using .NET remoting, as I believe that it is possible to encrypt the traffic and operate over untrusted networks such as the Internet.
#2 poses a much bigger problem. My experiments with .NET remoting have shown me that the application gets saturated very quickly. Using remote events and delegates, the client app simply can't keep up with the server and performance suffers to the point of being unusable. I'm a bit out of my depth on multithreading but I've seen MFC apps using sockets that don't need complex threading models to accomplish this so I'm not sure that multithreading is required here.
My questions are:
- For #1, I'd appreciate advice as to whether this sounds like a good idea and any pointers to how to encrypt the traffic.
- For #2, is there any example code that anyone can point me at which uses the .NET framework to get the performance I need, or ideas to help resolve this performance problem?
Any assistance and of course example code is welcomed!
|
|
|
|
|
You could take a look at either WCF, RabbitMQ, or NServiceBus, whatever is more appropriate for your scenario.
If you already have a working solution using MSMQ, then just make a secure tunnel - problem solved.
|
|
|
|
|
Hi-
I think this is pretty basic, but I'm not a coder...
I am using Visual Studio 2008 to create a web interface for an Access database. I can view, sort, edit my data in GridView but want to be able to have an expand/collapse feature. Not for a parent - child greidview. I just want to be able to see 5 records at a time and then when I click on the expand button be able to see all the records. Then when i hit collapse, I go back to only seeing 5 rows.
ANY advice is greatly appreciated.
Thanks
|
|
|
|
|
I believe you would get better suggestions/answers from Web Development[^] or ASP.NET[^] forum, depending on the technology you use.
Mika
|
|
|
|
|
I am new to Linux platform, i want to know that,
From where i can get Dot Net Framework for Linux platform ? and how i can run my dot net programs on to the Linux platform ?
please guide me.
|
|
|
|
|