Display Image based on cell criteria - c#

Using Visual Studio 2015 and C# here. I have a DataGridView based on one of my SQL tables. I have added in a DataGridViewImageColumn which is blank at the minute.
I need to somehow display an image in this cell based on the criteria which is ;
IF cell = Y then display image, if blank show nothing. I am relatively new to C# still if anybody could point me in the right direction that would be really helpful.
I'm not asking for somebody to write code for me, just if there is a function to go by that will help I can then look in to.
And YES I have of course googled it many times and tried various bits of code amending to fit my criteria / solution, I cannot get any of them to work.

Related

Is there a way in a Blazor Server app to get mouse coordinates clicked

I am trying to get motivated to move one of my open source projects called Transparency Maker from Windows Forms to Blazor, so I can put the app online.
All of the image editing is done via text in a language called BQL (Bitmap Query Language) which is very similar to SQL.
The one thing I don't know how to do in Blazor is get the x, y position of where the image is clicked. Windows Forms makes this very simple, although I have to do some scaling.
Is there a JavaScript way of doing this and bringing it into Blazor?
This is a feature I have to have, or writing a query like this is impossible for the user to know what to type:
Update
Set Adjust Red -200
Where
X Between 1700 2591
Y Between 1930 2110
Total > 500
Notice the White part of the socks in the second image, only the white was changed because the Total (Red + Blue + Green) has to be greater than 500 to perform the adjustment.
Thanks if this is possible to get the position clicked?
I think more people might appreciate this tool once it is online. As it is, "selling" free software is actually harder than it should be.
Transparency Maker
https://github.com/DataJuggler/TransparencyMaker
I am posting an answer thanks to the help from dani (if you posted your answer here, I could mark it as the answer).
I had to do two things to make this work:
Add a using statement for
using Microsoft.AspNetCore.Components.Web;
I added the EventCallback e parameter, and I didn't have to change anything else.
public void Button_Clicked(MouseEventArgs e)
{
double x = e.ClientX;
}
I will probably have to write some trial and error code to go from where the image is located, to find what pixel was actually clicked, but now I am confident I can do this.
Many thanks Dani. I will name a hospital after you some day.

Adding a note to a cell in Google Drive spreadsheet using C#

I'm currently working on a C# program to write a set of test results to a spreadsheet on Google Drive, and under the current format the cell to which I'm writing has one data value in the cell and the other 5 in a note (not a comment) on the cell.
EX: 1.8 visible in the cell, and when the cursor hovers over said cell, a small box appears to the side containing
Average: 1810 ms
Highest: 1921 ms
Lowest: 1708 ms
StdDev: 78 ms
Median: 1787 ms
My program currently can access and write to the cells in the Google spreadsheet, but I can't find a way to create a note for the cell and write to that. Any help is welcome.
If you take a look at this, setting a comment in the described way will actually add a note to the cell. This might be a known issue for them but I guess works in your favor. Hope this helps. :)

Table to Chart and Chart to Table update

Can any one help me out..
I wanted to have a Line Chart .. The Data to be loaded from sqlserver to that Line Chart..
One can drag the Line chart values and adjust them..
I am trying this using ChartDirectory tool.
Link
Once after adjustment of line chart, the Values to be updated to the same table..
Hopefully this makes sense, if not let me know.
Is there any tools available for this ??
Like This I want
you should try this free online tool - www.cloudyexcel.com/excel-to-graph/

Get height of rendered text and images in MS Word

I'm creating a newspaper authoring system. Today I'm using Aspose.Words library to generate newspaper using Docx format as output, based on a lot of other documents as input.
The basic idea is to load a lot of articles documents into a List, then generate a final docx with newspaper.
We need to get the total height of a text (with images and tables) inside columns. As libraries like Aspose.Words deal with Docx format like DOM, there isn't way to know how text will be arranged inside columns. Then I can't know the real height.
We've worked in our own way to get this height. I'm using MeasureString() function from System.Drawing.Graphics namespace. It returns width and height used by string and I can estimate how many lines (and points or inches) it will use inside a column.
But it is very poor and we need a more decent solution. We are thinking to use OpenXML SDK to get this Height, can we?
Aspose.Words doesn't support a way to know it and all Render classes are private to the library.
Can you think a new way to get this height?
Thank you,
Daniel Koch
This property isn't exposed in Open XML or the SDK (or VBA/VSTO for that matter). How exactly the height is calculated is not in any documentation. Possibly the way you are doing it is a way to proceed.
Another possible way is to put your TextColumns in a Table Column/Cell and grab that height (but if it is two text columns in the cell and the first one "fills" the cell top to bottom and the second one doesn't, you'll still have the issue of not being able to calculate the size of the second one).
I have almost the same problem that you have.. But in my case I'm dealing with Questions inside an Test Exam..
Well nowadays, we are using RTF to build the questions and a RichTextBox the measure the height.. Just like that (http://blogs.technet.com/david_bennett/archive/2005/04/06/403402.aspx)..
And I wanna to migrate to DOCX.. But still no luck on how to measure the question with tables and images.. :-(
Right now I'm studying the Document Members (http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._document_members.aspx), to try to do with Word Automation..
Regards,
Bruno
Thank all for answer.
I finished it changing Aspose.Words to PDFLib. Now I can control pages, columns or anything using Postscript Points.
We keep Aspose.Words only to content import, but it isn't indicate to print newsletter.

Format Excel Chart Background using C#

I can already populate the data into the spreadsheet, create the chart based on the range I select. However, when it comes to formatting the actual chart I feel a bit lost as their are so many options!!
It is an xlCylinderBarStacked type chart. I simply need to make the color of the bars a nice light orange and make the background a light blue fading into white at the bottom.
Any idea's how to do this?
Just to close this question off. I played around a little with the properties and the following achieved the gradient effect on the background of the chart.
xlChart.Interior.Color = ColorTranslator.ToOle(Color.LightSkyBlue);
chart.ChartArea.Fill.TwoColorGradient(
Microsoft.Office.Core.MsoGradientStyle.msoGradientHorizontal,
1);
One good trick with Excel and other VBA-enabled apps is to manually create the formatting/content you require using the Excel GUI, whist recording a 'macro'. Once this is done you can then inspect the generated VBA to see how to use the API to acheive the same results programmatically. You will of course have to do some translation from VBA to C# but essentially the same methods should work.

Categories

Resources