|
Strings can be treated as an array of characters so you don't have to create "input arrays".
string a = "eef";
string b = "ddg";
Dictionary<char, <list<char>> dic = new ...
if ( a.Length == b.Length ) {
for ( int i = 0; i < a.Length; i++ ) {
if ( dic.ContainsKey( a[i] ) {
}
}
}
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
|
|
|
|
|
Hello, and thank you for your time to look out my question.
I forgot to say that I have to use only System, not list or dictionary, LINQ, and others. The course assignment requirements. I think that is more about the logic
|
|
|
|
|
Hi Friends,
I have a scenario where need to generate WordProcessing Report
Here is my template sample below
First Name: «FirstName»
Last Name: «LastName»
Here First Name and Last Name are keys and corresponding Merge-fields are («FirstName» & «LastName»)
Now I have to generate a report where these key and merge-fields need to repeat number of times according to the Employee record. Example if there are fice employees in database, i need to show all five employees record one after other with FirstName and LastName in sequence.
I tried with below code. But this wont help because the key and data value does not show as per template configuration.
Can you please tell me how can i achieve this in C#?
Thanks in advance.
|
|
|
|
|
You could achieve it faster in MS Word.
|
|
|
|
|
|
Search and replace; should be simple enough. What part of the code are you struggling with?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
For some reason when I display icons in the ListView control, they are slightly fuzzy, or blurred.
I'm taking the icons from executable files and displaying them next to the filename, like Windows File Explorer.
But in Windows File Explorer, the icons are crystal clear.
I have the color depth of the ListView image list set to 32 bits.
Anyone have an idea?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Sounds more like a resolution problem. Icons do not rescale well. Can you access different size icons from the exe?
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Yes, I can probably extract different sizes. The icons are being extracted by the ExtractIconEx Win32 function in a native DLL.
Does the ListView control offer the capability to display the same icon(s) at different sizes? So far I've only seen one small size and one large size.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard Andrew x64 wrote: Does the ListView control offer the capability to display the same icon(s) at different sizes? Beyond my pay grade, I'm sorry. Ask an expert.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
All I can do is ask everybody and hope an expert answers.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I assume this is related to your other question in the C/C++ forum. Are you sure you are extracting the correct icon, i.e. having the size that matches the ImageList properties?
|
|
|
|
|
I create the Icon object using the FromHandle method passing in the HICON of the extracted icon.
And when I check the size of the new Icon object, it reads 32 x 32, which is the same as the size I set for the ImageList.
Maybe the ListView is just bad at displaying icons?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
Great idea! I'll try that.
Thanks Richard.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Didn't think it would be necessary to ask: WPF, Windows Forms or UWP?
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
|
|
|
|
|
Windows Forms.
I tried Richard's suggestion of converting the icon to a bitmap before adding it to the ImageList, but that didn't fix the fuzziness.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
This sounds interesting:
Quote: Set the appropriate property—SmallImageList, LargeImageList, or StateImageList—to the existing ImageList component you wish to use.
Display Icons for ListView Control - Windows Forms .NET Framework | Microsoft Docs
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 don't see anything on that page that makes any difference.
Thanks for your taking the time to respond.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Without seeing any code I don't know if this will help. I fixed this problem in VB by converting the icon to a bitmap with the routine below. I also use ExtractIconEx. I found that icon.ToBitmap() loses resolution for some reason. Sorry, you'll have to convert to C#.
''' <summary>
''' Convert Icon to Bitmap with resizing.
''' </summary>
''' <param name="ic"></param>
''' <param name="sz"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function IconToBitmap(ByVal ic As Icon, ByVal sz As Size) As Bitmap
If ic Is Nothing Then Return Nothing
Dim sourceWidth As Integer = ic.Width
Dim sourceHeight As Integer = ic.Height
Dim dPercent As Double = 0
Dim dPercentW As Double = 0
Dim dPercentH As Double = 0
dPercentW = (sz.Width / sourceWidth)
dPercentH = (sz.Height / sourceHeight)
If (dPercentH < dPercentW) Then
dPercent = dPercentH
Else
dPercent = dPercentW
End If
Dim destWidth As Integer = (sourceWidth * dPercent)
Dim destHeight As Integer = (sourceHeight * dPercent)
Dim bm As Bitmap = New Bitmap(destWidth, destHeight, PixelFormat.Format32bppArgb)
bm.SetResolution(destWidth, destHeight)
Dim g As Graphics = Graphics.FromImage(bm)
'g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
' This gives the best quality
g.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor
g.DrawIcon(ic, New Rectangle(0, 0, destWidth, destHeight))
g.Dispose()
Return bm
End Function
|
|
|
|
|
Wow! Thanks Mr. Bump.
I'll give this a try. I am thankful that you have solved this problem.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I have got some assembly in my sub folder and I know how to load it.
The problem is with other assemblies in this folder that this assembly is depending on.
I'm guessing that application would search for them only in it's own directory when loading assembly and not at assembly location.
Now I know about AppDomain.AssemblyResolve, but how can I subscribe to it in my assembly so I don't have to mess around with it in my main application.
Or how can I load all dependent assemblies when my assembly is loaded.
|
|
|
|
|
koirat wrote: The problem is with other assemblies in this folder that this assembly is depending on. You should indicate exactly what the problem is. Maybe there is a fix.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
The problem is that assemblies that my loaded assembly is dependent on are not going to be loaded automatically from directory different than main executable file location.
|
|
|
|
|
I guess you have to ask yourself why you are dynamically loading instead of simply including a reference in the project. DLL hell all over again.
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
|
|
|
|