|
Maybe you can try to use a c# word automation component to create word document and header,footer.Just like the Spire.Doc
|
|
|
|
|
how to drag and drop row from one datagrid to another(both datagrid are having equal number of columns) in C#.net
|
|
|
|
|
Try starting with DragData Demo[^]. Take on the principles and google for anything you don't understand.
If you try to do it and get stuck, or get errors, then post a question with sample code, full details of error etc.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I have been using c# in vs 2008 (3.5) with sp1.
Restarted the machine and now I see I have lost the intellisense in the projects i.e. forms, classes..
What do I do to get the intellisense?
Thanks
|
|
|
|
|
This isn't a question for this forum. In future, please ask Visual Studio questions on the Visual Studio forums.
Seeing I'm in a good mood, this[^] might help.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
thanks for the link
|
|
|
|
|
I had .Net application which is a dll developed in c#. I want to send a message for an VC application whose EXE will be already running.
How can I do this?
|
|
|
|
|
|
Hello,
i have DataGridView, with ComboBox cell in it.
i want that after the client clicked a button, the combo will be cleaned like at the moment it was first created (index = -1).
how can i do it?
the only property that the cell exposes is Value, but when i set it to "null" or to empty string, it does not do the work. can i get the inner ComboBox somehow?
i spent a few good hours on this but no success so far.
Thank you, Liran.
|
|
|
|
|
have you tried casting the cell to a DataGridViewComboBoxCell first and then setting it through that?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I don't think you have Index property for DataGridViewComboBoxCell. MSDN link[^]
जय हिंद
|
|
|
|
|
Oh right, that's not very good then... suppose could just set the value to "" then (providing the style is not set to DropDownList) but then you could clear Items then reload them, that should reset it to it's default.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
The problem is, that the BindingSource behind the CurrentValue does not accept nulls, so it yells at me with exceptions that the value is not valid..
|
|
|
|
|
Set AllowDBNull property to true.
जय हिंद
|
|
|
|
|
If the column is databound, then:
1. Set the AllowDBNull property of the Valuemember column to true.
2. Create a DataRow with ValueMember column value as null and DisplayMember as "--Select--" or " ".
3. Insert this row at the first position of your datatable.
जय हिंद
|
|
|
|
|
Hi,
I have a User control,which have a textbox and a button,this user control is being used in a windows form.
The windows form have a method, which I want to call in user control.
can someone help me in doing this, code sample will be appreciated.
Thanks in Advance.
Regards
Mahesh
modified on Thursday, May 28, 2009 5:26 AM
|
|
|
|
|
well, in user control...
FormMain mainForm = (FormMain)this.Parent;
mainForm.CallFunction();
or you could store a static instance of your main form somewhere, then...
ClassStatic.MainForm.CallFunction();
or, probably what i would go for, create an event handler in the usercontrol that the main form is listening for... Then you just fire the event in your usercontrol... In user control class...
public delegate void MyUCEventHandler(object sender, EventArgs e);
public event MyUCEventHandler UCEvent;
protected virtual void OnEventCall(EventArgs e)
{
if(UCEvent != null)
UCEvent(this, e);
}
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Option 3 is the better from an OO point of view.
It is a better design aproach to 'inform' the outside when the state within a class changes. That way there is little or no coupling from the referenced class, in this case the control, and the referencing class, the form.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
ok, I admit I was assuming that the control was intended to be used in multiple forms. So how would you 'inform' the form of a change?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
musefan wrote: So how would you 'inform' the form of a change?
An event! I said, and Wavey Davey concurred, the event approach is the safestest.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Oh right, I misunderstood your post thinking you were saying that an event would not be the best option in this case. i.e if a control is only intended to be used in one form then it should talk directly with the form itself...
Nevermind
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Use musefan's 3rd option above - the event driven one. If you're just wanting the signature to be the standard
object sender, EventArgs e then you don't need to create your own delegate, just use EventHandler like this:
public event EventHandler UCEvent;
protected virtual void OnUCEvent(EventArgs e)
{
EventHandler eh = UCEvent;
if(eh != null)
eh(this, e);
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I agree with all of them! Use option 3.
If this is your first time doing this, then you may need more detail:
In your child form:
public partial class frmDetail : Form
{
public delegate void OnChangeHandler(object sender, EventArgs e);
public static event OnChangeHandler OnChange;
private void DoSomethingToChangeData()
{
OnChange(file, null);
}
}
In your main form:
public frmMain()
{
frmDetail.OnChange += new frmDetail.OnChangeHandler(OnChanged);
}
private void ChangeCards()
{
frmDetail fd = new frmDetail(currentDetail);
fd.ShowDialog();
}
private void OnChanged(object sender, EventArgs e)
{
FileChanged = true;
}
It is pretty simple when you get your head around it!
[edit] Changed to move add event handler out of frmDetail instance create - we don't want another event each time ChangeCards is called, do we? My brain is not working - it must be thursday [/edit]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
A few problems. Avoid the Onxxx for the event name, that should be saved for the method that raises the event - in your example the event should be either Changing or Changed dependending on when it's fired.
An inheritor of your class may need to add functionality so the event itself should be raised in a separate protected virtual method OnChanging or OnChanged with that method taking the event args.
In your child form snippet, you call the event directly. If there are no subscribers, this will generate a NullReferenceException. At a minimum you should null check.
protected virtual void OnChanged(EventArgs e)
{
if(Changed != null)
Changed(this, e);
} There is a possibility (unlikely) that 'Changed' could change between the null check and the event raise line, so either a copy should be created and work on that copy:
EventHandler eh = Changed;
if(eh != null)
eh(this, e); or it should be put in a try/catch block.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Sorry. (I feel really small, now)
Your comments are (as always) correct, so I modified it.
In the child form:
public partial class frmDetail : Form
{
public delegate void ChangeHandler(object sender, EventArgs e);
public static event ChangeHandler Changed;
protected virtual void OnChanged(EventArgs e)
{
ChangeHandler ch = Changed;
if (ch != null)
{
ch(this, e);
}
}
private void DoSomethingToChangeData()
{
OnChanged(null);
}
}
I am not sure a try - catch block would be a good idea: it's not an error to not have a handler, and the throw/catch will be slow. But that is just me.
In the main form:
public frmMain()
{
frmDetail.Change += new frmDetail.ChangeHandler(Changed);
}
private void ChangeCards()
{
frmDetail fd = new frmDetail(currentDetail);
fd.ShowDialog();
}
private void Changed(object sender, EventArgs e)
{
FileChanged = true;
}
Better?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|