|
Hi,
i have a report with the below structure
<group 1="">
<group 1="" header="">
<group2 footer="">
i'm trying to export this report to excel with repeated headers and footers with N number of rows to print the report..
After setting the page break calculations and repeat header and footers, the report does not break with the exact N number of rows..
i have few merged rows inside the report and conditions to hide rows..
Appreciate if some one could help me to achieve this... its really urgent
thanks in advance
|
|
|
|
|
This issue I have it for a while, almost 1 year or more. I tried diverse permutations but always got stuck at some point, when the whole idea will not work anymore. And I give up all the time on it.
I have a class with properties, fields and methods in it. I am thinking to add events to it, but im not that great at them yet. When i call this class into form1 I basically change some values inside class, and the "object" that represents it, will add value or change color or change position ,etc.
If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. I had a lot of similar (and more complex) encounters with this subject and I simply freeze in the middle of it, not knowing how to manage it anymore.
Both ways are good! From outside or from inside class. But... sometime i need maneuverability, sometime is just in the way and i want it 'there' behind some close door(inside class I mean).
What your rules say about this thing? Should I change its values from inside the class? Or from outside?
Thank you.
------
thanks to OriginalGriff i relocated here the question.
q12
|
|
|
|
|
Don't sweat it, it's something you will learn to decide better as time goes.
As a rule, if your property has public setter it implied people will set it from outside!
Property usually have very simple set/get behaviour. But you could imagine the class having an Update() method that does some property updating.
As well as an external agent modifying them wen needed.
|
|
|
|
|
_Q12_ wrote: If i have a game let's say, when the character stays and I want him to look like it's breathing, this property should be inside the class? or outside, letting me choose when to breathe, how much, how long, how fast,etc. It's just an example. Inside, since it is part of.
_Q12_ wrote: Both ways are good! Nope.
Breathing would be done by a "AirSupplier", a base class that both Lungs and Gills inherit from. That way you can instantiate a fish with gills, and a rat with lungs. Add an IBreathable interface for quick filtering of breathing things.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Your character (class) could have a "Timer" that regulates breathing (and maybe another "ticker" for a heart).
Then you can "attach" (using "component composition") an air supply to your character.
Inside the air supply, you can have another timer so that eventually the air "runs out".
You can attach a "progress bar" (another component) to your character that goes to blue as air runs out.
Think "components"; and how to build more complicated components and scenarios from them.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hello friends,
I am working on a bio metric project, it returns a blob and we need to save it in Mysql Database,
I would like to ask how a blob is saved into mysql database when we have it in a byte array.
Thanks in advance.
|
|
|
|
|
Create a connection, issue appropriate command.
c# - Saving Byte[] Array to MYSQL - Stack Overflow[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
hi all, I have a base class usercontrol consisting of the usual text boxes , labels etc which I have subclassed into several other classes and have a problem in that when I open any of the sub classes in the VS designer all of the controls ( buttons etc... ) are locked and i can't delete or change any properties - any ideas ? It's been a long time since I've done any Winform work so bear with me
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
If the buttons etc. are part of the base class, then you can't move them in the designer by editing the derived class - if you think about it that's the only sensible way to go, as your base class could be in a compiled DLL instead of being available via source code (and thus can't be changed anyway!)
You should see a little padlock at the top left of base class controls indicating they can't be moved or deleted.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yes I suppose that's true - basically what I'm doing is dynamically loading the user controls into tab pages at runtime - some of them require slight modifications to the layout depending which page they are part off - I'll have to think of another way of achieving it - thanks for replying
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
You're welcome!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You can manipulate the Controls in sub-classed Controls (or Forms) at run time.
If you're really interested in "getting deep," I'll show you how it is done ... and I do not refer to the hack of changing the Designer 'cs file access type to 'public for UserControls.
Let me know if you want to go further: I'm burned out on posting code here that gets no response.
cheers, Bill
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Definitely interested Bill
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Okay, keeping in mind what OriginalGriff said about not being able to move sub-classed Controls at design-time ... or edit any of their properties ...
By "publishing" a data structure that exposes the run-time created Controls: you can modify them any way you like. I prefer to create a Dictionary<string, Control> ... and, here's how I do that: note the code you see here uses Extension methods in the 'ControlExtensions class appended to this post ... depending on task at hand, I may want only to expose the top-level Controls, or I may want to recurse to get nested Controls.
Example: In the sub-classed UserControl Load EventHandler:
public Dictionary<string, Control> ControlDict;
private void SubClassOfBaseUserControl_Load(object sender, t[EventArgs e)
{
ControlDict = this.Controls.FindAll();
ControlDict["button1"].Text - "changed."
} The limits of this are, of course, that you can't access the unique properties of Controls ... those which are not inherited from Control ... unless you up-cast back to their native Type. That's as simple as using 'as, or as complex as using reflection when you don't know the Type to up-cast to.
Hope this helps, and I;m not saying you should do things this way. cheers, Bill
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace YourNameSpace
{
public static class ControlExtensions
{
public static Dictionary<string, Control> FindAll(this Control.ControlCollection controls, bool recurse = true)
{
if (recurse)
{
return GetAllControls(controls).ToDictionary(c => c.Name, c => c); ;
}
else
{
return controls.Cast<Control>()
.ToDictionary(c => c.Name, c => c);
}
}
public static IEnumerable<Control> GetAllControls(Control.ControlCollection controls)
{
Stack<Control> stack = new Stack<Control>(controls.Cast<Control>().ToArray());
while (stack.Any())
{
var nextControl = stack.Pop();
foreach (Control childControl in nextControl.Controls)
{
stack.Push(childControl);
}
yield return nextControl;
}
}
}
}
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Whoah interesting stuff Bill, did you ever find a way of visually removing controls ?
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
pkfox wrote: did you ever find a way of visually removing controls Hi, do you mean something more than setting their 'Visible property to 'false ? ummm ... when you got a reference, you can do whatever:
ControlDict = this.Controls.FindAll();
Control theButton = ControlDict["button1"];
theButton.BackColor = Color.FromArgb(255, 230, 0);
theButton.Location = new Point(0, 0);
theButton.Hide();
ControlDict.Remove(theButton.Text);
theButton.Parent.Controls.Remove(theButton); To pursue this further and compare these rather hackish caniptions with another WinForm app strategy, it would interest me to have a clearer idea of what you want to achieve ... the other strategy would be using what I call the "switchboard model," with a static class handling all inter-form/control interactions and visual state changes... a poor-boy's MVC, perhaps.
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
modified 2-Dec-18 11:33am.
|
|
|
|
|
Hi Bill, thank you for your time and effort on this. What I have is a Winform with a custom TabControl which loads custom TabPages at runtime , the TabPages in turn load their respective UserControls. The user controls are for the most part the same and as they implement an Interface have guaranteed data properties and methods. Recently a requirement arose which entailed removing and adding controls ( which is when I discovered this can't be done visually) The application is a front end for a report generator which basically passes parameters to stored procedures and returns data in the form of Excel spreadsheets. I think I can achieve this using your method but if you know of another way please let me know, once again thank you for your time.
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
Okay, first take a look at this: [^] and this: [^] ... a custom Designer, and the right Attributes on the UserControl class definition, can enable a UserControl to have Controls drag-drop added at design-time.
It's been a while since I have messed with doing this, and I don't think that design-time facility will extend to sub-classed UserControls ... but, I'm not sure.
A custom designer (one I actually wrote) might look like this:
using System.ComponentModel;
using System.Windows.Forms.Design;
namespace YourNameSpace
{
public class TestControlDesigner : ParentControlDesigner
{
public override void Initialize(IComponent component)
{
base.Initialize(component);
if (Control is InheritedPanel)
EnableDesignMode((InheritedPanel) Control, Control.Name);
else if (Control is InheritedPanelHost) EnableDesignMode((InheritedPanelHost) Control, Control.Name);
}
}
} Note the reference to 'InheritedPanel and 'InheritedPanelHost above: Classes I created:
using System.ComponentModel;
using System.Windows.Forms;
namespace YourNameSpace
{
[Designer(typeof(TestControlDesigner))]
public partial class InheritedPanel : UserControl
{
public InheritedPanel()
{
InitializeComponent();
}
}
} Do familiarize yourself with Attributes that enable design-time property-grid editing as shown in use here;
using System.ComponentModel;
using System.Windows.Forms;
namespace YourNameSpace
{
[Designer(typeof(TestControlDesigner))]
public partial class PanelBase : UserControl
{
public PanelBase()
{
InitializeComponent();
}
[Category("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public TreeView TV { get; private set; }
[Category("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Panel TopPanel { get; private set; }
[Category("Appearance")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public Panel LowerPanel { get; private set; }
public void setPanelLabel(string s)
{
label1.Text = s;
}
private void PanelBase_Load(object sender, EventArgs e)
{
}
}
} cheers, Bill
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
modified 2-Dec-18 13:45pm.
|
|
|
|
|
@pkfox ... follow-up:Quote: a custom TabControl which loads custom TabPages Is the TabControl a sub-classed WinForm TabControl, or a 3rd. party commercial Control, or one you built "from scratch" ? Same question about the TabPage.
cheers, Bill
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
They're both sub classes of the Windows.Forms classes TabControl and TabPage
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
I wanted to mimic .net core and use an appSettings.Json file, well it didn't work out. Guess .Net Core Extensions won't work in my project. So I wrote some code using Newtonsoft, could not read the file and parse out pure JSON. Well I was able to read the file but not able to deserialize it. Searched the internet and found a couple of solutions that didn't pan out as well. So I searching for a NuGet package and found one, but no documentation.
Anybody used or found a package that they like?
I just want to read and write my MongoDB connection string.
Side Note,
really liking Mongo for this project!
except for this part. But I got some automated code to load and program Mongo going now, just need to finish this up.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Newtonsoft works for me:
string strConnect = "my connection string";
string json = Newtonsoft.Json.JsonConvert.SerializeObject(strConnect);
...
string readback = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(json); It doesn't have to be a string, it can be any class instance! So a "Settings" class that includes your connection information maybe? Or a list of Settings objects?
List<Setting> readback = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Setting>>(json);
The world is the mollusc of your choice!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I've been working with Newtonsoft this morning and still can't deserialize. hmm...
I'll post my code
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I'm not sure this will help, but why not use the built-in JSON package in .NET-framework 4.0 or later?
For instance try this:
1) Create a new console application.
2) Add a reference to System.Web.Extensions.dll.
3) Paste the following code:
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var list = new List<Person>();
list.Add(new Person() { Name = "Dude", Age = 21 });
list.Add(new Person() { Name = "Chap", Age = 28 });
var json = new JavaScriptSerializer();
var result = json.Serialize(list);
var listFromJson = json.Deserialize(result, typeof(List<Person>)) as List<Person>;
}
}
class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
} Just debug and step through the code to verify it works
I have serialized and deserialized a List<t> with a custom class.
You can of course serialize/deserialize whatever you want.
Best regards,
/Steffe
|
|
|
|
|
I saw a couple examples of that while searching, but passed on it because I had already written code.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|