|
|
Hy,
Can anyone tell me a way to supress the paint event in Windows Forms?
I have on my form several controls and I don't want them to be redrawn when I maximize the form (for example).
Thanks
Do your best to be the best
|
|
|
|
|
Any time the state of the window changes (maximize, minimize, move a mouse, drag a form across....) it invalidates the view since that view is no longer valid. If you suppressed the Paint event then your controls would disappear from the view by the vary nature of Invalidate(). I'm curious as to the logic behind not redrawing the controls...perhaps there is another route that keeps your controls visible.
|
|
|
|
|
If you want to prevent the Paint event from firing (which is a very odd thing to do, btw), then you can override OnPaint and do not call the base implementation. The base impl fires the event.
:josh:
My WPF Blog[^]
|
|
|
|
|
Hi @all,
i have a big problem. I want to read an attribute from the following XML-File:
-------------
<main>
<equations>
<rule name = "equation1"
calc = "D=A+B+3*C"></rule>
<rule name = "equation2"
calc = "E=A*B+C*D"></rule>
<rule name = "equation3"
calc = "C=B/A"></rule>
</equations>
<values>
<rule name = "equation1">
<Source obj = "12.3"
field = "A"></Source>
<Source obj = "1"
field = "B"></Source>
<Source obj = "23"
field = "C"></Source>
</rule>
<rule name = "equation2">
<Source obj = "1"
field = "A"></Source>
<Source obj = "1"
field = "B"></Source>
<Source obj = "7"
field = "C"></Source>
<Source obj = "6"
field = "D"></Source>
</rule>
<rule name = "equation3">
<Source obj = "12.3"
field = "A"></Source>
<Source obj = "1"
field = "B"></Source>
</rule>
</values>
</main>
---------------
So tried to get the "equation1" from the first rule segment in value with the following code:
-----------------
XPathDocument document = new XPathDocument("test.xml");
XPathNavigator navigator = document.CreateNavigator();
XPathNodeIterator name = navigator.Select("main/values/rule[0]");
string i = name.Current.GetAttribute("name", string.empty);
-----------------
or:
-----------------
XPathNodeIterator name =navigator.Select("main/values/rule[0]/@name");
if (name.MoveNext())
{
string i = name.Current.Value;
}
-----------------
Nothing works! I'am getting an empty string (""). If I debug I see name->Current->HasAttribute = false.
I dont know what I can do. Can you help me please?
Thank you very much!
(sorry for my english, my native language is not english
-- modified at 9:39 Monday 10th July, 2006
|
|
|
|
|
Hy,
When I'm working with XML files I always use XmlDocument. Try this and see if it works:
XmlDocument document = new XmlDocument();
document.Load("file.xml");
XmlNode node = document.DocumentElement.ChildNodes[0];
Then use the node.Attributes[ <index or="" name="">] to get the attribute. If you want to do this for every node there is an XmlNodeList class which can be used.
Do your best to be the best
|
|
|
|
|
You can use something like this:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("test.xml");
XmlNode equationsNode = xmlDoc.ChildNodes[0].ChildNodes[0] as XmlNode;
XmlNode valueNode = xmlDoc.ChildNodes[0].ChildNodes[1] as XmlNode;
foreach(XmlNode xmlNode in equationsNode)
{
XmlAttribute nameAttr = xmlNode.Attributes["name"];
XmlAttribute calcAttr = xmlNode.Attributes["calc"];
Console.WriteLine(nameAttr.Value + " " + calcAttr.Value);
}
foreach(XmlNode xmlNode in valueNode)
{
foreach(XmlNode sourceNode in xmlNode.ChildNodes)
{
XmlAttribute objAttr = sourceNode.Attributes["obj"];
XmlAttribute fieldAttr = sourceNode.Attributes["field"];
Console.WriteLine(objAttr.Value + " " + fieldAttr.Value);
}
}
|
|
|
|
|
Thank you very very much Karkster and stancrm!!! This will help me much more!
Thanks again!
|
|
|
|
|
i have listBox with multi coulm
how can add control to item 1 in col 2 ??
control as comboBox
Palestine
|
|
|
|
|
A listbox is not multi-collumn. So you either have a custom control or you have a DataGridView and the answer would greatly differ based on each type of control.
United States
|
|
|
|
|
He probably means a ListView. If that's the case, he's SOL.
:josh:
My WPF Blog[^]
|
|
|
|
|
ListBox can be multicolumn (ListBox.MultiColumn = true) but these columns are not the same as ListView columns (in Details mode) or Grid columns. Every item in a ListBox can contain only a single value and there is no column2 of the item1. To understand how it works just create a ListBox with size 300x300, fill it with 100 items and set MultiColumn = true. Then set MultiColumn = false. And you will see difference between ListBox columns and Grid columns.
The answer is:
1. You can not add control to the column2 of the item1 because there is no column2 for the item1 in ListBox control.
2. You can not even add control to the item1's column1 because ListBox control doesn't allow it.
So if you want to add custom controls to the some list don't use ListBox control.
|
|
|
|
|
hi all,
this query :
string query = "insert into KiralamaBilgisi(Kasa,DovizCinsi,GunlukKira,ToplamKira,KiraBaslangic,KiraBitis,KiraSuresi,COSaati,KaydiYapan) values(" + Convert.ToInt32(txtOdaNo.Text) + ",'" + txtDovizCin.Text + "'," + Convert.ToInt32(txtGunlukKBedel.Text) + "," + Convert.ToDouble(txtToplamKBedel.Text) + ",#" + Convert.ToDateTime(txtKiraBaslangic.Text).ToShortDateString() + "#,#" + Convert.ToDateTime(txtKiraBitis.Text).ToShortDateString() + "#," + Convert.ToInt32(txtKiraSuresi.Text) + ",'" + cmbCOSaati.Text + "','" + lblUserName.Text + "')";
doesnt return any error if my regional and language options is English...
but it returns: Number of query values and destination fields are not the same
whats wrong with date values? what should i do so as to make my program work both for english and turkish computers ???
thanks in advance, bye.
|
|
|
|
|
Mehmet Fatih Akbulut wrote: values(" + Convert.ToInt32(txtOdaNo.Text) + ",
This parameter in values will be treated as a single string. If you actually debugged your code and looked at your query variable you would answer your own question in 2 seconds.
You probably want :
values("'" + Convert.ToInt32(txtOdaNo.Text) + "'", ...
|
|
|
|
|
Hi
I want to know how to change the skin of a Windows Form. How can I change replace the MaximizeBox of a Windows Form as example. I don't want to use third party components. I just want to write my own stuff. But yet, i don't know how. Can anyone shortly explain how to make my own Windows Form or to replace the header with a grphic..
Thx
|
|
|
|
|
Try to see this example:
http://www.codeproject.com/cs/miscctrl/GoogleTalkWindowsForm.asp
|
|
|
|
|
|
Hy,
To create a skin for a windows form i use images. Set an images as the background image of your form and also set the border style of the form to None. The image I use has already drawn on it a maximize box and other buttons. I only put a label on top of these buttons and handle the click event. Using this method you can place buttons everywhere on the form.
Hope my suggestion helps
Do your best to be the best
|
|
|
|
|
Hi!
I have a ListView with two date-columns, "started", and "ended". I want them all to be sorted on the "started" column, but I want all the rows without an "ended" value separated and displayed before rows with "ended" value, like this:
Started Ended
050101
051110
051231
050101 061231
050910 061231
Ive done an ListViewItemSorter thingie, but I can't seem to make it sort with two separate columns:
class ListViewSortering : IComparer <br />
{<br />
private int col;<br />
public ListViewSortering() <br />
{<br />
col=0;<br />
}<br />
public ListViewSortering(int column) <br />
{<br />
col=column;<br />
}<br />
public int Compare(object x, object y) <br />
{<br />
return -String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);<br />
}<br />
}
And the call:
this.wmLvInsatser.Sorting = SortOrder.None;<br />
this.wmLvInsatser.ListViewItemSorter = new ListViewSortering(1);<br />
<br />
this.wmLvInsatser.Sort();
Can anyone point me in the right direction?
-- modified at 7:27 Monday 10th July, 2006
|
|
|
|
|
Hi,
the following modification should work:
class ListViewSortering : IComparer
{
private int colStart;
private int colEnd;
public ListViewSortering()
{
colStart=0;
colEnd=0;
}
public ListViewSortering(int columnStart, int columnEnd)
{
colStart=columnStart;
colEnd=columnEnd;
}
public int Compare(object x, object y)
{
ListViewItem lvi1 = (ListViewItem)x;
ListViewItem lvi2 = (ListViewItem)y;
string start1 = lvi1.SubItems[colStart].Text;
string end1 = lvi1.SubItems[colEnd].Text;
string start2 = lvi2.SubItems[colStart].Text;
string end2 = lvi2.SubItems[colEnd].Text;
if (end1.Length == 0 && end2.Length > 0)
return -1;
if (end1.Length > 0 && end.Length == 0)
return 1;
return -String.Compare(start1, start2);
}
}
So basically when only one of both items doesn't have an end date you'll return a special result value. In all other cases the normal comparison is done.
Robert
|
|
|
|
|
I'll try that out, thanks alot!
-- modified at 9:56 Monday 10th July, 2006
Worked like a charm
|
|
|
|
|
Where can I find Articles on transforming .Doc file to a single string so i can keep it in the DB
thank you
what's hard we do what's impossible will just take longer time to complete
|
|
|
|
|
Probably this is the one you are looking for:
http://www.codeproject.com/csharp/convertdocintootherformat.asp
|
|
|
|
|
Depending on your intended usage of the data it would be more effecient to store the document in a binary field.
|
|
|
|
|
I want to run queries on the string and find specific words
may be you have another idea?
thanks
what's hard we do what's impossible will just take longer time to complete
|
|
|
|