TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Varsha Vekariya
NA
101
14.7k
How to set autosuggest of DataGridComboBoxColumn WPF?
Apr 25 2019 1:25 AM
<
DataGridComboBoxColumn
x:Name
=
"list_itemname"
Width
=
"*"
Header
=
"Item Name"
>
<
DataGridComboBoxColumn.ElementStyle
>
<
Style
TargetType
=
"ComboBox"
>
<
Setter
Property
=
"IsEditable"
Value
=
"True"
/>
<
Setter
Property
=
"ItemsSource"
Value
=
"{Binding Path=itemlist }"
/>
</
Style
>
DataGridComboBoxColumn.ElementStyle
>
<
DataGridComboBoxColumn.EditingElementStyle
>
<
Style
TargetType
=
"ComboBox"
>
<
Setter
Property
=
"IsEditable"
Value
=
"True"
/>
<
Setter
Property
=
"ItemsSource"
Value
=
"{Binding Path=itemlist }"
/>
</
Style
>
</
DataGridComboBoxColumn.EditingElementStyle
>
</
DataGridComboBoxColumn
>
C# Code:
public
partial
class
page_addsale : Page
{
List itemlist =
new
List();
ObservableCollection<Proxy> collection =
new
ObservableCollection<Proxy>();
DataTable item_dt =
new
DataTable();
public
page_addsale()
{
InitializeComponent();
con.Open(); OleDbDataAdapter ad =
new
OleDbDataAdapter(
"select id, item_name from item_list"
, con);
ad.Fill(item_dt);
con.Close();
}
public
class
Proxy
{
public
string
itemname {
get
;
set
; }
public
string
itemunit {
get
;
set
; }
}
private
void
add_sale_Loaded(
object
sender, RoutedEventArgs e)
{
item_list.CanUserAddRows =
true
;
item_list.AutoGenerateColumns =
false
;
string
[] arr_item = item_dt.AsEnumerable().Select<System.Data.DataRow, String>(x => x.Field<String>(
"item_name"
)).ToArray();
itemlist.AddRange(arr_item);
list_itemname.ItemsSource = itemlist;
item_list.ItemsSource = collection;
}
}
after tab in unit column then DataGridComboBoxColumn selected item empty
Reply
Answers (
1
)
How to get the Current Cell Value in datagrid wpf ?
How to change the Number Format in localization for WPF ?