|
OK, for future reference, this site is about writing code.
You posted your question in a forum dedicated to writing Windows Forms apps.
|
|
|
|
|
My WinForms project has a DataGridView component which among other things shows PASS/FAIL text data.
I would like to replace any "PASS" with a check-mark image and any "FAIL" with a cross image but I'm not sure how to achieve this. Any assistance would be appreciated.
|
|
|
|
|
|
Thanks. It is working now. I first created an image column.
DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
iconColumn.HeaderText = "Pass/Fail";
iconColumn.Width = 60;
iconColumn.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
iconColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
iconColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
CalGrid.Columns.Insert(2, iconColumn);
I then used the CellFormatting event to set the correct image.
private void CalGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (CalGrid[3,e.RowIndex].Value.ToString() == "PASS")
{
e.Value = imageList1.Images[0];
}
else
{
e.Value = imageList1.Images[1];
}
}
|
|
|
|
|
Use a symbol font with a larger FontSize; e.g. Wingdings.
If it's Windows 10, the MS font Segoe MDL2 Assets has the windows icons and Segoe UI Symbol are the "pre" MDL2 icons. And there's Segoe UI Emoji ✅✔☠ for color.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I am currently writing a WinForms application in C# with a Microsoft Access database backend and using Crystal Reports for reporting.
One table in the database contains a numeric field which can allow any numeric value including zero, but is can also be Null. Currently when I display a report any field that contains a zero value is displayed as empty. I have played around with the "Show zero as" setting but it is either blank for both zero and Null values or it shows "0" for both zero and Null values.
I would like to display "0" for zero values and "" for Null values.
Any Crystal Reports gurus out there?
|
|
|
|
|
Been a while since I have used crystal reports, you will need to use a formula field. In your formula, it is also important to test IsNull first.
Crystal Syntext below,
If IsNull({Table.Field})
" "
Else
{Table.Field}
Hope this helps,
Regards,
Tarco
|
|
|
|
|
I tried this however the syntax has to be:
If IsNull({Table.Field})
" "
Else
totext({Table.Field})
Even when I do this it displays "0". For some reason CR is converting all null values to zeros.
|
|
|
|
|
If you don't mind me asking, how are you connecting to the access database?
|
|
|
|
|
I'm using c# code to connect to the database as follows:
string sql = null;
OleDbConnection cnn = new OleDbConnection(Global.connectionStringAccess);
cnn.Open();
sql = "SELECT * FROM Register WHERE ItemNo = '" + Global.CurrentItem + "'";
OleDbDataAdapter dscmd = new OleDbDataAdapter(sql, cnn);
DataSet ds = new DataSet();
dscmd.Fill(ds, "Register");
cnn.Close();
string rptName = rptPath + "\\rptWorksheet.rpt";
cryRpt.Load(rptName);
cryRpt.SetDataSource(ds.Tables["Register"]);
crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh();
|
|
|
|
|
|
Don't do anything complex in Crystal. Use it as a rendering engine, just allow it to do the "pretty" stuff, like grouping, totals, bolding etc. It's great for that.
Use your database to create the output values you want. In your case maybe look at creating a view and using that as your source.
// TODO: Insert something here Top ten reasons why I'm lazy
1.
|
|
|
|
|
OK, I think I've found a workaround to fix the problem. I modified the SQL SELECT statement using the ISNULL function to replace Null values with a large negative number (NOTE: users are limited to entering only positive numbers or small negative numbers in these fields. I then used CR conditional formatting to make these large negative numbers invisible (white foreground/background).
I know its crude but it works.
|
|
|
|
|
Not really a good idea.
If someone prints on a different shade of paper. Or even viewing on the screen and the user has changed their colour settings.
Use the formula that you created for the conditional formatting and put it into your select statement.
// TODO: Insert something here Top ten reasons why I'm lazy
1.
modified 9-Jul-21 5:26am.
|
|
|
|
|
Is there a specific requirement to use MS Access as your database? Access really should only be used by itself, if used at all.
SQL Server Developer/Express is free: SQL Server Downloads | Microsoft[^]
I know this does not answer your original question about zeros/nulls w/Crystal Reports, but I could not overlook an opportunity to "try" and convince someone not to use MS Access....for anything, ever.
My recommendation is to port over the general table schema and data from MS Access into an SQL Server database, then you are only stuck with the nightmare that is Crystal reports.

modified 6-Jul-21 7:16am.
|
|
|
|
|
so, i was doing some programming with eclipse and stuff. But then i noticed that all of my .JAR files suddenly looked like a pinguin with some painting stuff on his hands. i need help, cause im not sure what is going on!! I use windows.
[SOLVED] I had to right click a JAR file, and "press open in application" then select Java JDK. For some reason i had two of those...
modified 1-Sep-20 4:03am.
|
|
|
|
|
Some other app has probably registered itself as handling .jar files so you need to re-associate them with java. Google "associate jar files with java" for steps on how to do this.
|
|
|
|
|
|
Hi All
I am very new to this and very lost at the moment help would be greatly appreciated.
I am trying to view the live feed from my hikvision camera in a SCADA package called Adroit.
I am able to add windows forms to Adroit but cant use the RSTP streaming protocol because my application is on a moving vehicle and cant afford to have a latency issue.
To my understanding the only way is to use the web server that has a live feed from the camera.
I can add a web browser to my page in Adroit but don't have access to a keyboard and mouse to insert the user and password on the camera web server.
I am hoping there is another way to do this?
Thanking all in advanced.
|
|
|
|
|
Hi,
I’m writing a new WinForms app (C#, .Net Core, Visual Studio 2019 Preview). The App was intended to take the form of an MDI Parent container with multiple MDI Child forms; however, I need to allow some of the child forms to leave the MDI Parent container and display on a second or third monitor. I really like the way that Visual Studio does this, the way it allows you to dock a pane within the main container but also allows you to drag panes out of the main container to show on a secondary monitor. Is that possible with an MDI parent/child scenario (I suspect not)? If not, what would be the best way to achieve it?
Thanks in advance
|
|
|
|
|
|
Thanks, will do. 
|
|
|
|
|
Working with a DataGridView and a custom control: Is it at all possible for an array to be a parameter in a custom control? The high and low limits for every cell in the grid may be different. It would be nice to have this 3 dimensional array to be part of the parameters.
I have read articles that say that it is not possible to have any array to be a parameter in a control. They suggest forgetting DataGridView and doing something like an array of textbox. The grids in the app are always a fixed size and never use scroll bars.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
michaelbarb wrote: have read articles that say that it is not possible In which case move the validation from the constructor to the events, trap the key up or leave event of each cell and validate the content in the event.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I have done this for a set of limits that apply to all cells. I even got it work on a per column basis by make a lot of separate parameters. I need every cell to have different limits. Trying to pass a large array of limits into a derived control of DataGridView is the problem.
So many years of programming I have forgotten more languages than I know.
|
|
|
|