|
Hi everybody,
I have DataGridView with notes and I need filtering but I dont know how I can filtering datagridview with bindingsource(object binding).
My code looks like this:
public class Note
{
public string Name {get;set;}
}
Form_load()
{
noteBindingSource.Filter = "Name = 'Jack'";
noteBindingSource.DataSource = NoteList.GetNoteList();
myDataGridView.DataSource = noteBindingSource;
}
But this isnt working. Result is all rows. I think "Filter" is unused.
Thanks for help
Bye
Marek
|
|
|
|
|
Try swapping the data source filter and assignment. You may be applying a filter to a binding source that has nothing in it.
Alteratively if GetNoteList is a table then you can use a filtered dataview (this is the option we use all the time)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am looking for help on how to speed up VB.NET (or C#) screen refresh speed.
I am in charge of writing a newer fancier user interface in .NET for an older legacy program. Because this needs to run on slow legacy machines I did a performance test and discovered the screen refresh speeds of VB6 is faster then .NET.
To do a head to head comparison I put together equivalent VB6 and VB.NET programs, each with a maximized form and 48 labels. Clicking on any label changes the background color of all the labels on the form. In VB6 there is barely a flicker as the colors change across the entire form all at once. In VB.NET you can see the color change moving across the form like a wave. To really see the problem it is best to try the following code on a slower machine (1GHz etc.)
In VB6 create a project MyProject and add a form MyForm with the following properties
Caption = "Screen Refresh test VB6"
BackColor = Black
WindowState = Maximized
On that form add a label MyLabel with the following properties:
Index = 0
Caption = "Hello World"
BackColor = Cyan
In the form add the following code:
Option Explicit
Const ROWS As Integer = 8
Const COLS As Integer = 6
Const PAD As Integer = 75 ' 5 pixels at 15 twips per pixel
Private colors(0 To 2) As Long
Private color As Integer
Private Sub Form_Load()
Dim index As Integer
colors(0) = vbCyan
colors(1) = vbYellow
colors(2) = vbGreen
For index = 1 To ROWS * COLS - 1
Call Load(MyLabel(index))
MyLabel(index).Caption = MyLabel(index).Caption & " " & CStr(index)
MyLabel(index).Visible = True
Next index
MyLabel(0).Caption = MyLabel(0).Caption & " 0"
End Sub
Private Sub Form_Resize()
Dim width As Single
Dim height As Single
Dim row As Integer
Dim col As Integer
Dim index As Integer
width = (Me.width - 60 - PAD * (COLS + 1)) \ COLS
height = (Me.height - 450 - PAD * (ROWS + 1)) \ ROWS
For col = 0 To COLS - 1
For row = 0 To ROWS - 1
index = col * ROWS + row
Call MyLabel(index).Move(PAD + col * (width + PAD), PAD + row * (height + PAD), width, height)
Next row
Next col
End Sub
Private Sub MyLabel_Click(index As Integer)
color = (color + 1) Mod 3
For index = 0 To ROWS * COLS - 1
MyLabel(index).BackColor = colors(color)
Next index
End Sub
The VB.NET program is virtually identical. Just create a windows project and past in the following code. This code defines a form and is self sufficient. It does not need the auto generated form code.
Public Class MyForm
Inherits System.Windows.Forms.Form
Private Const _ROWS As Integer = 8
Private Const _COLS As Integer = 6
Private Const _PAD As Integer = 5
Private _myLabel(_ROWS * _COLS - 1) As System.Windows.Forms.Label
Private _colors() As System.Drawing.Color = {Color.Cyan, Color.Magenta, Color.Yellow}
Private _color As Integer
Public Sub New()
Me.SuspendLayout()
For index As Integer = 0 To _ROWS * _COLS - 1
Me._myLabel(index) = New System.Windows.Forms.Label
Me._myLabel(index).BackColor = System.Drawing.Color.Cyan
Me._myLabel(index).Name = "MyLabel" & CStr(index)
Me._myLabel(index).TabIndex = index
Me._myLabel(index).Text = "Hello World " & CStr(index)
Me._myLabel(index).TextAlign = System.Drawing.ContentAlignment.MiddleCenter
AddHandler Me._myLabel(index).Click, AddressOf MyLabel_Click
Me.Controls.Add(Me._myLabel(index))
Next
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = FormStartPosition.CenterScreen
Me.WindowState = FormWindowState.Maximized
Me.BackColor = Color.Black
Me.Name = "MyForm"
Me.Text = "Screen Refresh Test VB.NET"
Me.ResumeLayout(False)
End Sub
Private Sub MyForm_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Dim resize As System.Drawing.Size = _
New System.Drawing.Size _
( _
(Me.ClientRectangle.Width - (_PAD * _COLS + 1)) \ _COLS, _
(Me.ClientRectangle.Height - (_PAD * _ROWS + 1)) \ _ROWS _
)
Me.SuspendLayout()
For col As Integer = 0 To _COLS - 1
For row As Integer = 0 To _ROWS - 1
With Me._myLabel(col * _ROWS + row)
.Size = resize
.Location = New System.Drawing.Point(_PAD + col * (.Width + _PAD), _PAD + row * (.Height + _PAD))
End With
Next
Next
Me.ResumeLayout()
End Sub
Private Sub MyLabel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
_color = (_color + 1) Mod _colors.Length
For index As Integer = 0 To _ROWS * _COLS - 1
Me._myLabel(index).BackColor = _colors(_color)
Next
End Sub
End Class
Any help or ideas would be appreciated. If there is a known solution please point me in the right direction.
|
|
|
|
|
Devan_Monroe wrote: I am in charge of writing a newer fancier user interface in .NET for an older legacy program.
Devan_Monroe wrote: each with a maximized form and 48 labels. Clicking on any label changes the background color of all the labels on the form.
So where is the "newer fancier user interface"? I mean if you are going to do the same garbage why bother rewriting?
led mike
|
|
|
|
|
This isn't the fancier interface. The code is there just to demonstrate that .NET is slower (as written). If there is any way to update the screen more quickly I'd love to hear about it.
|
|
|
|
|
Devan_Monroe wrote: If there is any way to update the screen more quickly I'd love to hear about it.
Ok. Using the newer fancier user interface approaches it will be way faster.
Does that help?
led mike
|
|
|
|
|
Well, double buffering would help, and; oh yes, it's standard with .NET.
|
|
|
|
|
I'll look into double buffering. If anyone else has ideas or suggestions please chime in.
Oh, and by "it's standard with .NET" do you mean that this is well known and people are just putting up with it?
|
|
|
|
|
I am still looking for a way to refresh multiple controls on the screen at the same time.
I have tried using double buffering. This works well for a single control that uses various graphics drawing methods. But sub-controls still refresh on the screen independently of each other and their container.
I have tried using WM_SETREDRAW windows message to turn off and back on updating of a control. This requires an invalidate or refresh afterward. The redrawing of the control and sub-controls still occur independently of each other.
Has anyone found any way to make a form and all of its sub-controls update on the screen at the same time? Any help is greatly appreciated.
|
|
|
|
|
Hi
I am populating a List<lisviewitem>. When i add this list to ListView it generates error. Sample is below:
List<listviewitem> lstItems = new List<listviewitem>();
ListViewItem item = null;
listView1.Items.Clear();
listView2.Items.Clear();
listView1.BeginUpdate();
listView2.BeginUpdate();
item = new ListViewItem("<<All>>");
item.Tag = 0;
lstItems.Add(item);
item = null;
for (int i = 0; i < DS.Tables["Table"].Rows.Count; i++)
{
item = new ListViewItem(DS.Tables["Table"].Rows[i]["Column1"].ToString());
item.Tag = DS.Tables["Table"].Rows[i]["Column2"];
lstItems.Add(item);
item = null;
}
listView1.Items.AddRange(lstItems.ToArray());
listView1.EndUpdate();
listView2.Items.AddRange(lstItems.ToArray());
listView2.EndUpdate();
listView1.Items[0].Checked = true;
listView2.Items[0].Checked = true;
lstItems = null;
Can anybody provide a better solution for this.
|
|
|
|
|
Welcome to CodeProject
You need to read the posting instruction for posting code like HTML, XML and Generics because they all use the '<' and '>' characters which require special handling since this forum is a Web based forum and therefore uses HTML which is a tag based language.
Also you can say things like:
Member 3875850 wrote: it generates error
You should post the exact error message and any other relevant information.
led mike
|
|
|
|
|
I want to store subscript and superscript like H20, H2SO4, 6th in sql server and also vb.net windows application also..
i'm using vb.net2005 ..
Please help me......... its urgent.
Bye
K.Mani
kanmani84@gmail.com
By
K.mani
|
|
|
|
|
kannanmani wrote: its urgent.
That's just plain rude.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
kannanmani wrote: Please help me......... its urgent.
Nope. It doesn't even make my top 10000 of urgent things to do today.
|
|
|
|
|
A string stores characters in some encoding, such as ASCII or Unicode.
Normally there is no formatting information, unless your string will be consumed by
a program that knows how to handle formatting (e.g. a PostScript document and a PS reader).
Simple stuff may be available in Unicode, and for sub/superscript digits you're in luck:
http://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts[^]
BTW make sure your database field accepts Unicode text.
BTW2: I fail to see how this fits this Windows Forms forum.
|
|
|
|
|
When hosting the WebBrowser control (in IE7), is there a setting to prevent it from ever opening a file open or save dialog. (Such as when you are gmail or yahoo mail and adding an attachment.) I'm currently just looking for and closing all child windows, but this is a bit too aggressive.
(Tools|Options|Security Tab|Internet Zone|Custom Settings, Downloads/File downloads/disable doesn't work.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi...,
I want to close my AboutForm by clicking somewhere, not only on the Form. Is there a general MouseEventHandler?
Thank you,
Michael
|
|
|
|
|
One simple way to achieve this behavior is to use Click event and LostFocus event of the Form. Such as –
---------------------------
Private Sub Form2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Me.Close()
End Sub
---------------------------
Private Sub Form2_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LostFocus
Me.Close()
End Sub
----------------------------
I hope this helps.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
Hi Dave,
thank you for this idea. This only works, when the focus goes to another application window. When the focus loses to the parent windows, nothing happens.
I think I still need a more bulletproof solution.
Thank anyway,
Michael
|
|
|
|
|
Hi Everyone I'm doing something where I want to draw multiple controls, without redrawing every time I e.g. resize. The Problem is that I don't want the user to see all the buttons redrawn, every time they e.g. resize the form - any suggestions?...I've tried with double buffering but can't seem to get the hang of it...
Here's an example of how to genereate my problem, then try to resize the form:
public void createButtons()
{
int xlen = 40;
int ylen = 50;
int xpos = 23;
int ypos = 12;
Button[,] buttons = new Button[xlen,ylen];
for (int i = 0; i < xlen; i++)
{
for (int k = 0; k < ylen; k++)
{
buttons[i, k] = new Button();
buttons[i, k].Location = new System.Drawing.Point(xpos, ypos);
buttons[i, k].Size = new System.Drawing.Size(26, 23);
ypos += 20;
this.Controls.Add(buttons[i, k]);
}
xpos += 30;
ypos = 12;
}
}
|
|
|
|
|
CoolAL wrote: int xlen = 40;
int ylen = 50;
2000 buttons? Are you kidding me?
led mike
|
|
|
|
|
Mabye he's building a system for George Jetson to use...gotta make sure that button pushin finger stays strong.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Use the following:
this.SuspendLayout();
this.ResumeLayout();
The SuspendLayout() method Suspends the drawing of the control until the ResumeLayout() method is called. So, call the SuspendLayout() method on the form and add the controls. After adding them, call the ResumeLayout() method on the form.
See the msdn page for SuspendLayout() method for a complete example!
|
|
|
|
|
|
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|