Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: hashtable limitation? Pin
Jassim Rahma17-Jun-10 4:06
Jassim Rahma17-Jun-10 4:06 
GeneralRe: hashtable limitation? Pin
Luc Pattyn17-Jun-10 4:14
sitebuilderLuc Pattyn17-Jun-10 4:14 
GeneralRe: hashtable limitation? Pin
Jassim Rahma17-Jun-10 4:17
Jassim Rahma17-Jun-10 4:17 
GeneralRe: hashtable limitation? Pin
Luc Pattyn17-Jun-10 4:21
sitebuilderLuc Pattyn17-Jun-10 4:21 
QuestionPng Image Saving the original size doubles Pin
VCsamir16-Jun-10 21:39
VCsamir16-Jun-10 21:39 
AnswerRe: Png Image Saving the original size doubles Pin
Luc Pattyn17-Jun-10 2:04
sitebuilderLuc Pattyn17-Jun-10 2:04 
Questionsearch in dataview without filtering Pin
sana_2616-Jun-10 21:13
sana_2616-Jun-10 21:13 
AnswerRe: search in dataview without filtering Pin
Bigdeak16-Jun-10 23:56
Bigdeak16-Jun-10 23:56 
Hi, you cannot select a row by a DataView. i assume that you have bindet the DataView to a DataGridView Control. In this case, the only method to "select" the rows instead of filter, i know, is my following example.

public partial class Form1 : Form
    {
        private DataView _dataView;

        public Form1()
        {
            InitializeComponent();

            for (int i = 0; i < 10000; i++)
            {
                dataSet1.Tables[0].Rows.Add("A" + i, "A", "A", "A");
                dataSet1.Tables[0].Rows.Add("Ae" + i, "Ae", "Ae", "Ae");
                dataSet1.Tables[0].Rows.Add("B" + i, "B", "B", "B");
                dataSet1.Tables[0].Rows.Add("Be" + i, "Be", "Be", "Be");
                dataSet1.Tables[0].Rows.Add("C" + i, "C", "C", "C");
                dataSet1.Tables[0].Rows.Add("D" + i, "D", "D", "D");
                dataSet1.Tables[0].Rows.Add("E" + i, "E", "E", "E");
                dataSet1.Tables[0].Rows.Add("F" + i, "F", "F", "F");
            }            
            
            _dataView = new DataView(dataSet1.Tables[0]);

            dataGridView1.DataSource = _dataView;
        }

        public void SelectRowsInView(string filter)
        {
            Dictionary<string, DataGridViewRow> dataGridViewRows = new Dictionary<string,DataGridViewRow>();

            DataRow[] dataRows = _dataView.Table.Select(filter);
                        
            foreach (DataGridViewRow dataGridViewRow in dataGridView1.Rows)
            {
                if (dataGridViewRow.Cells[0].Value != null){
                    dataGridViewRows.Add(dataGridViewRow.Cells[0].Value.ToString(), dataGridViewRow);
                }
            }

            dataGridView1.ClearSelection();

            foreach (DataRow row in dataRows)
            {
                if ( dataGridViewRows.ContainsKey( row[0].ToString() ) )
                {
                    dataGridViewRows[row[0].ToString()].Selected = true;
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SelectRowsInView("Column1 like 'B*'");
        }
    }


You have to use the primary key of the DataTable as Dictionary Key, there will be a exception, if you use a not non-ambiguous column as key, in this case, the primary key is index 0.

There a some performance optimizing by using a dictionary, i have desist from comment the source code, you can use the method SelectRowsInView as base idea. I hope i could help Smile | :)
Questionhow to get the methods registered with an eventhandler Pin
prasadbuddhika16-Jun-10 20:06
prasadbuddhika16-Jun-10 20:06 
AnswerMessage Closed Pin
16-Jun-10 21:31
stancrm16-Jun-10 21:31 
GeneralRe: how to get the methods registered with an eventhandler Pin
prasadbuddhika17-Jun-10 19:21
prasadbuddhika17-Jun-10 19:21 
QuestionNaming Controls Pin
SajjadZare16-Jun-10 18:47
SajjadZare16-Jun-10 18:47 
AnswerRe: Naming Controls Pin
Peace ON16-Jun-10 21:11
Peace ON16-Jun-10 21:11 
AnswerRe: Naming Controls Pin
Luc Pattyn17-Jun-10 2:06
sitebuilderLuc Pattyn17-Jun-10 2:06 
GeneralRe: Naming Controls Pin
SajjadZare17-Jun-10 6:01
SajjadZare17-Jun-10 6:01 
AnswerRe: Naming Controls Pin
yu-jian27-Jun-10 10:19
yu-jian27-Jun-10 10:19 
QuestionAssembelys Pin
future383916-Jun-10 15:20
future383916-Jun-10 15:20 
QuestionPerformance framework \ utility Pin
Berlus16-Jun-10 10:31
Berlus16-Jun-10 10:31 
AnswerRe: Performance measure on inline methods Pin
Berlus16-Jun-10 18:59
Berlus16-Jun-10 18:59 
QuestionCompact datagrid Pin
jashimu16-Jun-10 8:44
jashimu16-Jun-10 8:44 
AnswerRe: Compact datagrid Pin
hammerstein0516-Jun-10 10:33
hammerstein0516-Jun-10 10:33 
QuestionThread.Join Pin
Endien16-Jun-10 6:26
Endien16-Jun-10 6:26 
AnswerRe: Thread.Join Pin
harold aptroot16-Jun-10 6:33
harold aptroot16-Jun-10 6:33 
GeneralRe: Thread.Join Pin
Endien16-Jun-10 6:48
Endien16-Jun-10 6:48 
GeneralRe: Thread.Join Pin
harold aptroot16-Jun-10 6:54
harold aptroot16-Jun-10 6:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.