Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

How can we make a DatGridViewTextBoxColumn in a datagridview take the suggestAppend property in order to select a file from any location?

Please help!!!
Posted
Updated 25-May-14 20:11pm
v2

var DataResultCollection = new AutoCompleteStringCollection();

String[] tempArrayStr = Array.ConvertAll<datarow,>(Customer.Select(), delegate(DataRow row) { return (String)row["Address"]; });
DataResultCollection.AddRange(tempArrayStr);

TextBox txtAddress = e.Control as TextBox;
if (txtAddress != null)
{
txtAddress.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
txtAddress.AutoCompleteCustomSource = DataResultCollection;
txtAddress.AutoCompleteSource = AutoCompleteSource.CustomSource;

}


write this code in the " private void dataGridDetail_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) " ..I hope it is Useful to you..
 
Share this answer
 
Thanks guys but i got it myself!!

C#
private void dgvIsland_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            TextBox prodCode = e.Control as TextBox;
            if (datagridview1.CurrentCell.ColumnIndex == 2)
            {
                var source = new AutoCompleteStringCollection();
                
                if (prodCode != null)
                {
                    prodCode.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                    prodCode.AutoCompleteSource =AutoCompleteSource.FileSystem;
                }
            }
            else
                prodCode.AutoCompleteCustomSource = null;
        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900